VS:EqPt: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
No edit summary
 
(fix)
 
(9 intermediate revisions by the same user not shown)
Line 5: Line 5:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<desc>
<desc>
Returns TRUE if the 2D points are equal within the tolerance.
Returns TRUE if the 2D points are equal within the tolerance.</desc>
</desc>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<def>
<def>
<funcDef lang="vs">
<funcDef lang="vs">
FUNCTION EqPt(pt1X, pt1Y, pt1Z :REAL; pt2X, pt2Y, pt2Z :REAL; tolerance :REAL) :BOOLEAN;
FUNCTION EqPt(pt1:VECTOR; pt2:VECTOR; tolerance:REAL) : BOOLEAN;
</funcDef>
</funcDef>
<funcDef lang="py">
<funcDef lang="py">
Line 23: Line 22:
<lineList ident=1>
<lineList ident=1>
<line>
<line>
pt1X, pt1Y, pt1Z
pt1
REAL
VECTOR


</line>
</line>
<line>
<line>
pt2X, pt2Y, pt2Z
pt2
REAL
VECTOR


</line>
</line>
Line 39: Line 38:
</lineList>
</lineList>
</params>
</params>
-----------------------------------------------------------------------------------------------------------
<return>
</return>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
([[User:CBM-c-|_c_]], 2022.01.21) Tolerance must be <> 0. By a tolerance of 0 EqPt will always return false. In Python, contrary to most Pascal-derived vectorial routines, EqPt accepts also a bidimensional tuple without returning gibberish: the third item will always be ignored. So this is a 2D-only routine.


</remark>
</remark>
Line 52: Line 47:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample>
<sample>
==== Vectorscript ====
<code lang="pas">
<code lang="pas">
PROCEDURE Example;
PROCEDURE Example;
VAR
VAR
  pt1, pt2 :VECTOR;
    v1, v2 : VECTOR;
  tol      :REAL;
BEGIN
BEGIN
  Message('Specify the first point...');
    v1.x := 12; v1.y := 1;
  GetPt(pt1.x, pt1.y);
    v2.x := 12; v2.y := 1;
  Message('Specify the second point...');
    Message(Concat( EqPt(v1, v2, 0.1) ));
  GetPt(pt2.x, pt2.y);
  tol := RealDialog('Enter tolerance for comparison:', '0.001');
  IF EqPt(pt1, pt2, tol)
      THEN AlrtDialog(Concat(pt1, ' == ', pt2, ' in tolerance:', tol))
      ELSE AlrtDialog(Concat(pt1, ' != ', pt2, ' in tolerance:', tol))
END;
END;
RUN(Example);</code>
Run(Example);
</code>
 
==== Python ====
 
<code lang="py">
v1 = (12, 1, 999) # z vals in 3-dimensional tuples will be ignored
v2 = (12, 1, 0)
vs.Message( str(vs.EqPt(v1, v2, 0.1)) )
</code>


</sample>
</sample>
-----------------------------------------------------------------------------------------------------------
<seeAlso>
VS Functions:
* [[VS:EqualPt]]
* [[VS:EqPt2D]]
* [[VS:EqPt3D]]
</seeAlso>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<version>
<version>
Availability: from All Versions
Availability: from Vectorworks 2014


This is drop-in function.
</version>
</version>
-----------------------------------------------------------------------------------------------------------
<seeAlso>
</seeAlso>


</vwDoc>
</vwDoc>

Latest revision as of 04:30, 22 January 2022

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Returns TRUE if the 2D points are equal within the tolerance.

FUNCTION EqPt(
pt1 :VECTOR;
pt2 :VECTOR;
tolerance :REAL) : BOOLEAN;
def vs.EqPt(pt1, pt2, tolerance):
    return BOOLEAN

Parameters

pt1 VECTOR
pt2 VECTOR
tolerance REAL

Remarks

(_c_, 2022.01.21) Tolerance must be <> 0. By a tolerance of 0 EqPt will always return false. In Python, contrary to most Pascal-derived vectorial routines, EqPt accepts also a bidimensional tuple without returning gibberish: the third item will always be ignored. So this is a 2D-only routine.

Example

Vectorscript

PROCEDURE Example;
VAR
    v1, v2 : VECTOR;
BEGIN
    v1.x := 12; v1.y := 1;
    v2.x := 12; v2.y := 1;
    Message(Concat( EqPt(v1, v2, 0.1) ));
END;
Run(Example);

Python

v1 = (12, 1, 999) # z vals in 3-dimensional tuples will be ignored
v2 = (12, 1, 0)
vs.Message( str(vs.EqPt(v1, v2, 0.1)) )

Version

Availability: from Vectorworks 2014

See Also

VS Functions:

VS Functions:
  • [[VS:EqualPt]]
  • [[VS:EqPt2D]]
  • [[VS:EqPt3D]]