Span: Difference between revisions
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:SDK]] | [[Category:SDK]] | ||
[[File:Back.jpg|right|50px|link=Creating Vectors From Script]] | [[File:Back.jpg|right|50px|link=Creating Vectors From Script]] | ||
This object is the base class for spans in a Contour. Spans are either lines, arcs or beziers or a single | This object is the base class for spans in a Contour. Spans are either lines, arcs or beziers or a single ‘point’ | ||
‘point’ | |||
==Constructors== | ==Constructors== | ||
Line 9: | Line 7: | ||
===Span( Point3D pt3d)=== | ===Span( Point3D pt3d)=== | ||
A new span representing a single point is created within a Lua script using this | A new span representing a single point is created within a Lua script using this constructor method | ||
Line 32: | Line 30: | ||
===.EndPoint3D=== | ===.EndPoint3D=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Point3D) The 3D end point of the span | |||
Line 39: | Line 38: | ||
===.EndPoint2D=== | ===.EndPoint2D=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Point2D) The 2D end point of the span | |||
Line 45: | Line 45: | ||
===.IsLineType=== | ===.IsLineType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is a line | |||
Line 51: | Line 52: | ||
===.IsArcType=== | ===.IsArcType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is an arc | |||
Line 57: | Line 59: | ||
===.IsBezierType=== | ===.IsBezierType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is a bezier | |||
Line 63: | Line 66: | ||
===.IsLeadInType=== | ===.IsLeadInType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is a lead in | |||
Line 69: | Line 73: | ||
===.IsLeadOutType=== | ===.IsLeadOutType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is a lead out | |||
Line 75: | Line 80: | ||
===.IsOvercutType=== | ===.IsOvercutType=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Bool) true if span is part of an overcut | |||
Line 81: | Line 87: | ||
===.NumberOfControlPoints=== | ===.NumberOfControlPoints=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Integer) number of control points for span (2 for Bezier, 1 for an arc (the mid point), 0 for a line | |||
Line 87: | Line 94: | ||
===.StartPoint3D=== | ===.StartPoint3D=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Point3D) The 3D start point of the span | |||
Line 93: | Line 101: | ||
===.StartPoint2D=== | ===.StartPoint2D=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Point2D) The 2D start point of the span | |||
Line 99: | Line 108: | ||
===.Type=== | ===.Type=== | ||
'''Interaction:''' Read Only | |||
'''Returns:''' (Integer) enum identifying type of the span | |||
Usual values are Span.NormalLine, Span.Arc and Span.Bezier | Usual values are Span.NormalLine, Span.Arc and Span.Bezier | ||
Line 107: | Line 117: | ||
Methods | ==Methods== | ||
:ChordLength() | ===:ChordLength()=== | ||
Return the straight-line distance between start and end points of the span | Return the straight-line distance between start and end points of the span | ||
Line 117: | Line 127: | ||
:EndVector( bool normalise) | ===:EndVector( bool normalise)=== | ||
Return a Vector2D representing the direction of the span at the end. | Return a Vector2D representing the direction of the span at the end. | ||
Line 125: | Line 135: | ||
:GetControlPointPosition( integer index) | ===:GetControlPointPosition( integer index)=== | ||
Return a Point2D with position of requested control point (use .NumberOfControlPoints to get count). This call is only valid on a Bezier or an Arc. For a Bezier 0 returns first control point, 1 returns the second. For an arc, 0 returns arc mid point. | Return a Point2D with position of requested control point (use .NumberOfControlPoints to get count). This call is only valid on a Bezier or an Arc. For a Bezier 0 returns first control point, 1 returns the second. For an arc, 0 returns arc mid point. | ||
Line 131: | Line 141: | ||
index - integer - index of control point | index - integer - index of control point | ||
:GetLength( double tolerance) | ===:GetLength( double tolerance)=== | ||
Return a double holding the length of the span. The passed tolerance is used for beziers to approximate length to given tolerance. | Return a double holding the length of the span. The passed tolerance is used for beziers to approximate length to given tolerance. | ||
Line 141: | Line 151: | ||
tolerance - double - tolerance to use when polygonizing beziers to find length | tolerance - double - tolerance to use when polygonizing beziers to find length | ||
:MoveControlPoint( integer index, Point2D pt) | ===:MoveControlPoint( integer index, Point2D pt) === | ||
This is only valid for an arc or Bezier and attempts to move the specified control point to the passed position. This call is only valid on a Bezier or an Arc. For a Bezier, index 0 modifies first control point, 1 modifies the second. For an arc, 0 modifies the arc mid point. If the control point can’t be moved to the passed position (e.g would make an invalid arc) returns false, else true. | This is only valid for an arc or Bezier and attempts to move the specified control point to the passed position. This call is only valid on a Bezier or an Arc. For a Bezier, index 0 modifies first control point, 1 modifies the second. For an arc, 0 modifies the arc mid point. If the control point can’t be moved to the passed position (e.g would make an invalid arc) returns false, else true. | ||
Line 151: | Line 161: | ||
index - integer - index of control point pt - Point2D - position for control point | index - integer - index of control point pt - Point2D - position for control point | ||
:PointAtParameter( double param, double tolerance) | ===:PointAtParameter( double param, double tolerance) === | ||
Return a Point2D representing the point on the span at passed parameter in range 0 - 1.0. Passed tolerance is used for polygonisation for Bezier spans. | Return a Point2D representing the point on the span at passed parameter in range 0 - 1.0. Passed tolerance is used for polygonisation for Bezier spans. | ||
Line 167: | Line 177: | ||
:StartVector( bool normalise) | ===:StartVector( bool normalise)=== | ||
Return a Vector2D representing the direction of the span at the start. | Return a Vector2D representing the direction of the span at the start. | ||
Line 173: | Line 183: | ||
normalise - bool - if true, the returned vector is normalized | normalise - bool - if true, the returned vector is normalized | ||
:SetStartPoint3D( Point3D pt) | ===:SetStartPoint3D( Point3D pt)=== | ||
Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | ||
Line 183: | Line 193: | ||
pt - Point3D - 3D position for point | pt - Point3D - 3D position for point | ||
:SetStartPoint2D( Point2D pt) | ===:SetStartPoint2D( Point2D pt)=== | ||
Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | ||
Line 193: | Line 203: | ||
pt - Point2D - 2D position for point | pt - Point2D - 2D position for point | ||
:SetEndPoint3D( Point3D pt) | ===:SetEndPoint3D( Point3D pt)=== | ||
Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | ||
Line 203: | Line 213: | ||
pt - Point3D - 3D position for point | pt - Point3D - 3D position for point | ||
:SetEndPoint2D( Point2D pt) | ===:SetEndPoint2D( Point2D pt)=== | ||
Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour. | ||
pt - Point2D - 2D position for point | pt - Point2D - 2D position for point | ||
Latest revision as of 13:34, 30 August 2024
This object is the base class for spans in a Contour. Spans are either lines, arcs or beziers or a single ‘point’
Constructors
Span( Point3D pt3d)
A new span representing a single point is created within a Lua script using this constructor method
pt3d - Point3D - 3d position for a point
e.g
local pt = Point3D(0, 0, 0)
local pt_span = Span(pt)
NOTE: most spans are created as either a LineSpan, ArcSpan or BezierSpan.
Properties
.EndPoint3D
Interaction: Read Only
Returns: (Point3D) The 3D end point of the span
.EndPoint2D
Interaction: Read Only
Returns: (Point2D) The 2D end point of the span
.IsLineType
Interaction: Read Only
Returns: (Bool) true if span is a line
.IsArcType
Interaction: Read Only
Returns: (Bool) true if span is an arc
.IsBezierType
Interaction: Read Only
Returns: (Bool) true if span is a bezier
.IsLeadInType
Interaction: Read Only
Returns: (Bool) true if span is a lead in
.IsLeadOutType
Interaction: Read Only
Returns: (Bool) true if span is a lead out
.IsOvercutType
Interaction: Read Only
Returns: (Bool) true if span is part of an overcut
.NumberOfControlPoints
Interaction: Read Only
Returns: (Integer) number of control points for span (2 for Bezier, 1 for an arc (the mid point), 0 for a line
.StartPoint3D
Interaction: Read Only
Returns: (Point3D) The 3D start point of the span
.StartPoint2D
Interaction: Read Only
Returns: (Point2D) The 2D start point of the span
.Type
Interaction: Read Only
Returns: (Integer) enum identifying type of the span
Usual values are Span.NormalLine, Span.Arc and Span.Bezier
Methods
:ChordLength()
Return the straight-line distance between start and end points of the span
:EndVector( bool normalise)
Return a Vector2D representing the direction of the span at the end.
normalise - bool - if true, the returned vector is normalised
:GetControlPointPosition( integer index)
Return a Point2D with position of requested control point (use .NumberOfControlPoints to get count). This call is only valid on a Bezier or an Arc. For a Bezier 0 returns first control point, 1 returns the second. For an arc, 0 returns arc mid point.
index - integer - index of control point
:GetLength( double tolerance)
Return a double holding the length of the span. The passed tolerance is used for beziers to approximate length to given tolerance.
tolerance - double - tolerance to use when polygonizing beziers to find length
:MoveControlPoint( integer index, Point2D pt)
This is only valid for an arc or Bezier and attempts to move the specified control point to the passed position. This call is only valid on a Bezier or an Arc. For a Bezier, index 0 modifies first control point, 1 modifies the second. For an arc, 0 modifies the arc mid point. If the control point can’t be moved to the passed position (e.g would make an invalid arc) returns false, else true.
index - integer - index of control point pt - Point2D - position for control point
:PointAtParameter( double param, double tolerance)
Return a Point2D representing the point on the span at passed parameter in range 0 - 1.0. Passed tolerance is used for polygonisation for Bezier spans.
parameter - double - parameter in range 0 - 1.0 to find point on span at tolerance - double - tolerance to use when polygonizing beziers :Reverse()
Reverse the span - swap start and end points and for arcs swap sign of bulge, for beziers swap control points.
:StartVector( bool normalise)
Return a Vector2D representing the direction of the span at the start.
normalise - bool - if true, the returned vector is normalized
:SetStartPoint3D( Point3D pt)
Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour.
pt - Point3D - 3D position for point
:SetStartPoint2D( Point2D pt)
Set start point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour.
pt - Point2D - 2D position for point
:SetEndPoint3D( Point3D pt)
Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour.
pt - Point3D - 3D position for point
:SetEndPoint2D( Point2D pt)
Set end point for span - be EXTREMELY careful if you call this method on spans in a contour as gaps will open between adjoining spans leading to an invalid contour.
pt - Point2D - 2D position for point
References
Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 2.05, published September 12, 2018. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information