VS:LineCircleIntersect: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 5: Line 5:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<desc>
<desc>
Finds the intersection points of a line and a circle.
Finds the intersection points of a line and a circle.</desc>
 
Returns false if there is no intersection.
</desc>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<def>
<def>
<funcDef lang="vs">
<funcDef lang="vs">
FUNCTION LineCircleIntersect(begPtX, begPtY, begPtZ :REAL; endPtX, endPtY, endPtZ :REAL; cenPtX, cenPtY, cenPtZ :REAL; radius :REAL; VAR pt1X, pt1Y, pt1Z :REAL; VAR pt2X, pt2Y, pt2Z :REAL) :BOOLEAN;
FUNCTION LineCircleIntersect(begPt:VECTOR; endPt:VECTOR; cenPt:VECTOR; radius:REAL; VAR pt1:VECTOR; VAR pt2:VECTOR) : BOOLEAN;
</funcDef>
</funcDef>
<funcDef lang="py">
<funcDef lang="py">
Line 25: Line 22:
<lineList ident=1>
<lineList ident=1>
<line>
<line>
begPtX, begPtY, begPtZ
begPt
REAL
VECTOR


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


</line>
</line>
<line>
<line>
cenPtX, cenPtY, cenPtZ
cenPt
REAL
VECTOR


</line>
</line>
Line 45: Line 42:
</line>
</line>
<line>
<line>
pt1X, pt1Y, pt1Z
pt1
REAL
VECTOR
Output parameter.
 
</line>
</line>
<line>
<line>
pt2X, pt2Y, pt2Z
pt2
REAL
VECTOR
Output parameter.
 
</line>
</line>
</lineList>
</lineList>
</params>
</params>
-----------------------------------------------------------------------------------------------------------
<return>
</return>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark>
 
In VS Python, this function returns 3-element tuples with gibberish in the third element regardless whether you give it 2- or 3-element tuples.
This function checks and returns the intersection of the circle with an infinite line defined by the two supplied points.
</remark>
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample>
<sample></sample>
<code lang="pas">
PROCEDURE Example;
VAR
  cen_pt, beg_pt, end_pt :VECTOR;
  startAng, sweepAng, Radius :REAL;
  pt1, pt2 :VECTOR;


  PROCEDURE ArcInfo(h :HANDLE; VAR cen_pt :VECTOR; VAR startAng, sweepAng, Radius :REAL);
-----------------------------------------------------------------------------------------------------------
  BEGIN
<seeAlso></seeAlso>
      Hcenter(h, cen_pt.x, cen_pt.y);
      GetArc (h, startAng, sweepAng);
      IF GetType(h) = 6 THEN Radius := Hperim(h) / Deg2Rad(sweepAng) ELSE
      IF GetType(h) = 89 THEN Radius := 5729.28 / ((100 * Hangle(h)) / Hlength(h));
  END;
 
BEGIN
  CallTool(-205); ArcInfo(FSActLayer, cen_pt, startAng, sweepAng, Radius);
  CallTool(-201);
  GetSegPt1(FSActLayer, beg_pt.x, beg_pt.y);
  GetSegPt2(FSActLayer, end_pt.x, end_pt.y);
  IF LineCircleIntersect(beg_pt, end_pt, cen_pt, Radius, pt1, pt2) THEN BEGIN
      Locus(pt1.x, pt1.y);
      Locus(pt2.x, pt2.y);
  END;
END;
RUN(Example);</code>
 
</sample>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<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 23:30, 26 January 2023

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

Description

Finds the intersection points of a line and a circle.

FUNCTION LineCircleIntersect(
begPt :VECTOR;
endPt :VECTOR;
cenPt :VECTOR;
radius :REAL;
VAR pt1 :VECTOR;
VAR pt2 :VECTOR) : BOOLEAN;
def vs.LineCircleIntersect(begPt, endPt, cenPt, radius):
    return (BOOLEAN, pt1, pt2)

Parameters

begPt VECTOR
endPt VECTOR
cenPt VECTOR
radius REAL
pt1 VECTOR
pt2 VECTOR

Remarks

In VS Python, this function returns 3-element tuples with gibberish in the third element regardless whether you give it 2- or 3-element tuples.

This function checks and returns the intersection of the circle with an infinite line defined by the two supplied points.

Version

Availability: from Vectorworks 2014