VS:RelativeCoords: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
 
m (fix)
 
(5 intermediate revisions by the same user not shown)
Line 5: Line 5:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<desc>
<desc>
Translates a point into a coordinate system defined by 2 other points.
Translates a point into a coordinate system defined by 2 other points.</desc>
</desc>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<def>
<def>
<funcDef lang="vs">
<funcDef lang="vs">
FUNCTION RelativeCoords(ptX, ptY, ptZ :REAL; begPtX, begPtY, begPtZ :REAL; endPtX, endPtY, endPtZ :REAL) X, Y, Z :REAL;
FUNCTION RelativeCoords(pt:VECTOR; begPt:VECTOR; endPt:VECTOR) : VECTOR;
</funcDef>
</funcDef>
<funcDef lang="py">
<funcDef lang="py">
Line 23: Line 22:
<lineList ident=1>
<lineList ident=1>
<line>
<line>
ptX, ptY, ptZ
pt
REAL
VECTOR


</line>
</line>
<line>
<line>
begPtX, begPtY, begPtZ
begPt
REAL
VECTOR


</line>
</line>
<line>
<line>
endPtX, endPtY, endPtZ
endPt
REAL
VECTOR


</line>
</line>
Line 40: Line 39:
</params>
</params>


-----------------------------------------------------------------------------------------------------------
<remark>
([[User:CBM-c-|_c_]], 2022.01.19) In Python the tuple returned is always bidimensional in the form (0.0, 0.0).
Remember to add a third item (0.0, 0.0, 0.0) for usage in the vector Routines such as VS:Vec2Ang or they will return gibberish.
See graphical representation below (click on the image to enlarge it):
[[File:C_MathRelativeCoords.png|200px ]]


-----------------------------------------------------------------------------------------------------------
[MaKro 11/2021] Did not dig deeper, but looks like beg and end can be interpreted as: vs.RelativeCoords(p, p_origin, x_axis)
<return>
</return>


-----------------------------------------------------------------------------------------------------------
<remark>
([[User:Orso.b.schmid|Orso]], 2011 Jan. 21): As shown in the example below, it also accepts three vectors. For the math-ignorant (such as me): you can visually understand the effect of this routine as follows:
* draw a line between "begPt-endPt". This line has perhaps an angle.
* rotate the line using as fulcrum "begPt" so that it lies horizontally on the x-axes. Now the angle is zero
* shift the line on the user origin so that "begPt" lies on it
You can see an image of this representation on the [http://www.vectorlab.info/index.php?title=Image:MathRelativeCoords.png Math page of Vectorlab]
</remark>
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample>
<sample>
<code lang="pas">
 
==== VectorScript ====
 
<code lang=pas>
PROCEDURE Example;
PROCEDURE Example;
VAR
VAR
  pt, beg_pt, END_pt, v :VECTOR;
    pt, beg_pt, end_pt, v :VECTOR;
 
BEGIN
BEGIN
  Message('Set begin point...');
    Message('Set begin point');
  CallTool(-221); { call the "Locus" tool }
    CallTool(-221); { creates a locus }
  GetLocPt(FSActLayer, beg_pt.x, beg_pt.y); { fetch locus coordinates }
    GetLocPt(FSActLayer, beg_pt.x, beg_pt.y);
  Message('Set end point...');
 
  CallTool(-221);
    Message('Set end point');
  GetLocPt(FSActLayer, END_pt.x, END_pt.y);
    CallTool(-221); { creates a locus }
  Message('Set point...');
    GetLocPt(FSActLayer, end_pt.x, end_pt.y);
  CallTool(-221);
 
  GetLocPt(FSActLayer, pt.x, pt.y);
    Message('Set point');
  v := RelativeCoords(pt, beg_pt, END_pt);
    CallTool(-221); { creates a locus }
  Message('result vector=', v);
    GetLocPt(FSActLayer, pt.x, pt.y);
 
    v := RelativeCoords(pt, beg_pt, end_pt);
    Message('result vector=', v);
    Locus(v.x, v.y);
END;
END;
RUN(Example);</code>
RUN(Example);
</code>
 
==== Python ====
<code lang="py">
</code>


</sample>
</sample>
-----------------------------------------------------------------------------------------------------------
<seeAlso></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 06:15, 21 January 2022

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

Description

Translates a point into a coordinate system defined by 2 other points.

FUNCTION RelativeCoords(
pt :VECTOR;
begPt :VECTOR;
endPt :VECTOR) : VECTOR;
def vs.RelativeCoords(pt, begPt, endPt):
    return VECTOR

Parameters

pt VECTOR
begPt VECTOR
endPt VECTOR

Remarks

(_c_, 2022.01.19) In Python the tuple returned is always bidimensional in the form (0.0, 0.0).

Remember to add a third item (0.0, 0.0, 0.0) for usage in the vector Routines such as VS:Vec2Ang or they will return gibberish.

See graphical representation below (click on the image to enlarge it):

[MaKro 11/2021] Did not dig deeper, but looks like beg and end can be interpreted as: vs.RelativeCoords(p, p_origin, x_axis)

Example

VectorScript

PROCEDURE Example;
VAR
    pt, beg_pt, end_pt, v :VECTOR;

BEGIN
    Message('Set begin point');
    CallTool(-221); { creates a locus }
    GetLocPt(FSActLayer, beg_pt.x, beg_pt.y);

    Message('Set end point');
    CallTool(-221); { creates a locus }
    GetLocPt(FSActLayer, end_pt.x, end_pt.y);

    Message('Set point');
    CallTool(-221); { creates a locus }
    GetLocPt(FSActLayer, pt.x, pt.y);

    v := RelativeCoords(pt, beg_pt, end_pt);
    Message('result vector=', v);
    Locus(v.x, v.y);
END;
RUN(Example);

Python


Version

Availability: from Vectorworks 2014