VS:RelativeCoords

From Vectorworks Developer
Revision as of 14:36, 12 August 2013 by Root (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.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(
ptX, ptY, ptZ :REAL;
begPtX, begPtY, begPtZ :REAL;
endPtX, endPtY, endPtZ :REAL) X, Y, Z :REAL;
def vs.RelativeCoords(pt, begPt, endPt):
    return VECTOR

Parameters

ptX, ptY, ptZ REAL
begPtX, begPtY, begPtZ REAL
endPtX, endPtY, endPtZ REAL

Remarks

(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 Math page of Vectorlab

Example

PROCEDURE Example;
VAR
   pt, beg_pt, END_pt, v :VECTOR;
BEGIN
   Message('Set begin point...');
   CallTool(-221); { call the "Locus" tool }
   GetLocPt(FSActLayer, beg_pt.x, beg_pt.y); { fetch locus coordinates }
   Message('Set end point...');
   CallTool(-221);
   GetLocPt(FSActLayer, END_pt.x, END_pt.y);
   Message('Set point...');
   CallTool(-221);
   GetLocPt(FSActLayer, pt.x, pt.y);
   v := RelativeCoords(pt, beg_pt, END_pt);
   Message('result vector=', v);
END;
RUN(Example);

Version

Availability: from All Versions

This is drop-in function.