ArcSpan: Difference between revisions

From SDK
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
This object represents an arc span in a Contour. It is derived from the Span class and all methods and properties of the span class are valid on this object as well. As well as creating spans to append to a contour you can use the ArcTo methods to avoid span creation. Arcs are represented internally using the start and end points and a ‘bulge factor’ which controls the shape of the arc. The bulge represents a ratio between the chord length of an arc and its height (bulge = (2*arc_height) / chord_length).
[[File:Back.jpg|right|50px|link=Creating Vectors From Script]]
[[Category:SDK]]
 
This object represents an arc span in a Contour. It is derived from the Span class and all methods and properties of the span class are valid on this object as well. As well as creating spans to append to a contour you can use the ArcTo methods to avoid span creation. Arcs are represented internally using the start and end points and a ‘bulge factor’ which controls the shape of the arc. The bulge represents a ratio between the chord length of an arc and its height (bulge = (2 * arc_height) / chord_length).


== Constructors ==
== Constructors ==
Line 6: Line 9:
  - Constructor -
  - Constructor -
A new span representing an arc is created within a Lua script using this contructor method
A new span representing an arc is created within a Lua script using this contructor method
start_pt – Point2D – 2D position for start point of span
::''start_pt – Point2D – 2D position for start point of span
end_pt – Point2D – 2D position for end point of span- must have same Z values as start
::''end_pt – Point2D – 2D position for end point of span- must have same Z values as start
pt_on_arc- Point2D – 2D position for a point on arc
::''pt_on_arc- Point2D – 2D position for a point on arc


----
----
Line 14: Line 17:
::''NOTE: arcs can be a maximum of 180 degrees
::''NOTE: arcs can be a maximum of 180 degrees
::''e.g
::''e.g
::''local start_pt = Point2D(0, 0)
<nowiki> local start_pt = Point2D(0, 0)
::''local end_pt = Point2D(1.0, 0)
local end_pt = Point2D(1.0, 0)
::''local pt_on_arc = Point2D(0.5, 0.3)
local pt_on_arc = Point2D(0.5, 0.3)
::''local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc)
local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc) </nowiki>
 
==== ArcSpan(Point2D start_pt, Point2D end_pt, Point2D centre_pt, bool ccw) ===


-- Constructor --
===ArcSpan(Point2D start_pt, Point2D end_pt, Point2D centre_pt, bool ccw) - Constructor ===


A new span representing an arc is created within a Lua script using this contructor method
A new span representing an arc is created within a Lua script using this contructor method
Line 30: Line 31:
::''ccw - bool - true if arc is Counter Clockwise
::''ccw - bool - true if arc is Counter Clockwise


::''e.g
:: e.g
::''local start_pt = Point2D(0, 0)
<nowiki> local start_pt = Point2D(0, 0)
::''local end_pt = Point2D(1.0, 0)
local end_pt = Point2D(1.0, 0)
::''local center_pt = Point2D(0.5, 0)
local center_pt = Point2D(0.5, 0)
::''local arc_span = ArcSpan(start_pt, end_pt, center_pt, false)
local arc_span = ArcSpan(start_pt, end_pt, center_pt, false) </nowiki>


::''NOTE: arcs can be a maximum of 180 degrees
:: NOTE: arcs can be a maximum of 180 degrees
::''96


=== ArcSpan(Point3D start_pt, Point3D end_pt, Point3D centre_pt, bool ccw) ===


-- Constructor --
=== ArcSpan(Point3D start_pt, Point3D end_pt, Point3D centre_pt, bool ccw) - Constructor ===


A new span representing an arc is created within a Lua script using this contructor method
A new span representing an arc is created within a Lua script using this contructor method
Line 48: Line 47:
::''centre_pt - Point3D - 3d position for centre point of arc (not mid-point)
::''centre_pt - Point3D - 3d position for centre point of arc (not mid-point)
::''ccw - bool - true if arc is Counter Clockwise
::''ccw - bool - true if arc is Counter Clockwise
::''e.g
::''e.g
::''local start_pt = Point3D(0, 0, 0)
::''local start_pt = Point3D(0, 0, 0)
::''local end_pt = Point3D(1.0, 0, 0)
::''local end_pt = Point3D(1.0, 0, 0)  
local center_pt = Point3D(0.5, 0, 0)
::local center_pt = Point3D(0.5, 0, 0)
local arc_span = ArcSpan(start_pt, end_pt, center_pt, false)
::local arc_span = ArcSpan(start_pt, end_pt, center_pt, false)
NOTE: arcs can be a maximum of 180 degrees
::NOTE: arcs can be a maximum of 180 degrees
ArcSpan(Point3D start_pt, Point3D end_pt, Point2D pt_on_arc) - Constructor
 
=== ArcSpan(Point3D start_pt, Point3D end_pt, Point2D pt_on_arc) - Constructor ===
 
A new span representing an arc is created within a Lua script using this contructor method
A new span representing an arc is created within a Lua script using this contructor method
start_pt - Point3D – 3D position for start point of span
::''start_pt - Point3D – 3D position for start point of span
end_pt - Point3D – 3D position for end point of span- must have same Z values as start
::''end_pt - Point3D – 3D position for end point of span- must have same Z values as start pt_on_arc- Point2D – 2D position for a point on arc
pt_on_arc- Point2D – 2D position for a point on arc
 
NOTE: arcs can be a maximum of 180 degrees
:: NOTE: arcs can be a maximum of 180 degrees  
e.g
 
local start_pt = Point3D(0, 0, 0)
::''e.g  
local end_pt = Point3D(1.0, 0, 0)
::''local start_pt = Point3D(0, 0, 0)  
local pt_on_arc = Point2D(0.5, 0.3)
::''local end_pt = Point3D(1.0, 0, 0)  
local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc)
::''local pt_on_arc = Point2D(0.5, 0.3)  
ArcSpan(Point2D start_pt, Point2D end_pt, double bulge) - Constructor
::''local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc)  
A new span representing an arc is created within a Lua script using this contructor method
 
start_pt – Point2D – 2D position for start point of span
=== ArcSpan(Point2D start_pt, Point2D end_pt, double bulge) - Constructor ===
end_pt – Point2D – 2D position for end point of span - must have same Z values as start
 
bulge - double - buge factor for arc
A new span representing an arc is created within a Lua script using this contructor method start_pt – Point2D – 2D position for start point of span end_pt – Point2D – 2D position for end point of span - must have same Z values as start bulge - double - buge factor for arc e.g local start_pt = Point2D(0, 0) local end_pt = Point2D(1.0, 0) local arc_span = ArcSpan(start_pt, end_pt, 1.0)  
e.g
 
local start_pt = Point2D(0, 0)
=== ArcSpan(Point3D start_pt, Point3D end_pt, double bulge) - Constructor ===
local end_pt = Point2D(1.0, 0)
 
local arc_span = ArcSpan(start_pt, end_pt, 1.0)
A new span representing an arc is created within a Lua script using this contructor method start_pt - Point3D – 3D position for start point of span end_pt - Point3D – 3D position for end point of span - must have same Z values as start bulge - double - buge factor for arc e.g local start_pt = Point3D(0, 0, 0) local end_pt = Point3D(1.0, 0, 0) local arc_span =
97
 
ArcSpan(Point3D start_pt, Point3D end_pt, double bulge) - Constructor
=== ArcSpan(start_pt, end_pt, 1.0) ===
A new span representing an arc is created within a Lua script using this contructor method
 
start_pt - Point3D – 3D position for start point of span
NOTE: arcs can be a maximum of 180 degrees  
end_pt - Point3D – 3D position for end point of span - must have same Z values as start
 
bulge - double - buge factor for arc
== Properties ==
e.g
 
local start_pt = Point3D(0, 0, 0)
=== .Bulge ===
local end_pt = Point3D(1.0, 0, 0)
R/O - double - signed bulge for arc  
local arc_span = ArcSpan(start_pt, end_pt, 1.0)
 
NOTE: arcs can be a maximum of 180 degrees
=== .IsAntiClockwise ===
Properties
R/O - bool - true if arc is anticlockwise (same as .IsCCW)  
.Bulge
 
R/O - double - signed bulge for arc
=== .IsCCW ===
.IsAntiClockwise
R/O - bool - true if arc is counter clockwise (same as . IsAntiClockwise)  
R/O - bool - true if arc is anticlockwise (same as .IsCCW)
 
.IsCCW
===.IsClockwise ===
R/O - bool - true if arc is counter clockwise (same as . IsAntiClockwise)
R/O - bool - true if arc is clockwise (same as . IsCW )  
.IsClockwise
 
R/O - bool - true if arc is clockwise (same as . IsCW )
===.IsCW ===
.IsCW
R/O - bool - true if arc is clockwise (same as . IsClockwise)  
R/O - bool - true if arc is clockwise (same as . IsClockwise)
 
Methods
== Methods ==
:ArcMidPoint()
 
=== :ArcMidPoint() ===
Returns a Point3D holding the mid point of the arc
Returns a Point3D holding the mid point of the arc
:RadiusAndCentre(Point3D ret_centre_pt)
 
=== :RadiusAndCentre(Point3D ret_centre_pt) ===
Calculate the centre point of the arc and the radius. The method returns the radius and also sets the position of the passed point to the centre point position of the arc.
Calculate the centre point of the arc and the radius. The method returns the radius and also sets the position of the passed point to the centre point position of the arc.
ret_centre_pt - Point3D - returned 3d position for centre point of arc (not mid-point)
ret_centre_pt - Point3D - returned 3d position for centre point of arc (not mid-point)
Example Code
 
local arc = ArcSpan(Point3D(0,0,0), Point3D(1,0,0), 1.0)
Example Code
local centre = Point3D()
<nowiki>
local radius = arc:RadiusAndCentre(centre)
local arc = ArcSpan(Point3D(0,0,0), Point3D(1,0,0), 1.0)
MessageBox("Arc Radius = " .. radius ..
local centre = Point3D()
" Centre Point = " .. centre.x .. "," .. centre.y )
local radius = arc:RadiusAndCentre(centre)
:SetBulge(bulge)
MessageBox("Arc Radius = " .. radius ..
" Centre Point = " .. centre.x .. "," .. centre.y ) </nowiki>
 
 
=== :SetBulge(bulge) ===
Set the bulge factor for this arc
Set the bulge factor for this arc
Bulge - double - bulge factor for arc
Bulge - double - bulge factor for arc
98


---
---
Line 122: Line 129:
::''end -Point2D -End point for arc
::''end -Point2D -End point for arc
::''mid -Point2D -mid point for arc ( NOT centre point)
::''mid -Point2D -mid point for arc ( NOT centre point)
[[File:Back.jpg|right|50px|link=Creating Vectors From Script]]
==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 [https://gadgets.vectric.com/developerinfo.html Vertric Developer Information]

Latest revision as of 08:32, 31 August 2024

Back.jpg

This object represents an arc span in a Contour. It is derived from the Span class and all methods and properties of the span class are valid on this object as well. As well as creating spans to append to a contour you can use the ArcTo methods to avoid span creation. Arcs are represented internally using the start and end points and a ‘bulge factor’ which controls the shape of the arc. The bulge represents a ratio between the chord length of an arc and its height (bulge = (2 * arc_height) / chord_length).

Constructors

ArcSpan(Point2D start_pt, Point2D end_pt, Point2D pt_on_arc)

- Constructor -

A new span representing an arc is created within a Lua script using this contructor method

start_pt – Point2D – 2D position for start point of span
end_pt – Point2D – 2D position for end point of span- must have same Z values as start
pt_on_arc- Point2D – 2D position for a point on arc

NOTE: arcs can be a maximum of 180 degrees
e.g
 local start_pt = Point2D(0, 0)
 local end_pt = Point2D(1.0, 0)
 local pt_on_arc = Point2D(0.5, 0.3)
 local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc) 

ArcSpan(Point2D start_pt, Point2D end_pt, Point2D centre_pt, bool ccw) - Constructor

A new span representing an arc is created within a Lua script using this contructor method

start_pt – Point2D – 2D position for start point of span
end_pt – Point2D – 2D position for end point of span- must have same Z values as start
centre_pt – Point2D – 2D position for centre point of arc (not mid-point)
ccw - bool - true if arc is Counter Clockwise
e.g

local start_pt = Point2D(0, 0) local end_pt = Point2D(1.0, 0) local center_pt = Point2D(0.5, 0) local arc_span = ArcSpan(start_pt, end_pt, center_pt, false)

NOTE: arcs can be a maximum of 180 degrees


ArcSpan(Point3D start_pt, Point3D end_pt, Point3D centre_pt, bool ccw) - Constructor

A new span representing an arc is created within a Lua script using this contructor method

start_pt - Point3D - 3d position for start point of span
end_pt - Point3D - 3d position for end point of span- must have same Z values as start
centre_pt - Point3D - 3d position for centre point of arc (not mid-point)
ccw - bool - true if arc is Counter Clockwise
e.g
local start_pt = Point3D(0, 0, 0)
local end_pt = Point3D(1.0, 0, 0)
local center_pt = Point3D(0.5, 0, 0)
local arc_span = ArcSpan(start_pt, end_pt, center_pt, false)
NOTE: arcs can be a maximum of 180 degrees

ArcSpan(Point3D start_pt, Point3D end_pt, Point2D pt_on_arc) - Constructor

A new span representing an arc is created within a Lua script using this contructor method

start_pt - Point3D – 3D position for start point of span
end_pt - Point3D – 3D position for end point of span- must have same Z values as start pt_on_arc- Point2D – 2D position for a point on arc
NOTE: arcs can be a maximum of 180 degrees
e.g
local start_pt = Point3D(0, 0, 0)
local end_pt = Point3D(1.0, 0, 0)
local pt_on_arc = Point2D(0.5, 0.3)
local arc_span = ArcSpan(start_pt, end_pt, pt_on_arc)

ArcSpan(Point2D start_pt, Point2D end_pt, double bulge) - Constructor

A new span representing an arc is created within a Lua script using this contructor method start_pt – Point2D – 2D position for start point of span end_pt – Point2D – 2D position for end point of span - must have same Z values as start bulge - double - buge factor for arc e.g local start_pt = Point2D(0, 0) local end_pt = Point2D(1.0, 0) local arc_span = ArcSpan(start_pt, end_pt, 1.0)

ArcSpan(Point3D start_pt, Point3D end_pt, double bulge) - Constructor

A new span representing an arc is created within a Lua script using this contructor method start_pt - Point3D – 3D position for start point of span end_pt - Point3D – 3D position for end point of span - must have same Z values as start bulge - double - buge factor for arc e.g local start_pt = Point3D(0, 0, 0) local end_pt = Point3D(1.0, 0, 0) local arc_span =

ArcSpan(start_pt, end_pt, 1.0)

NOTE: arcs can be a maximum of 180 degrees 

Properties

.Bulge

R/O - double - signed bulge for arc

.IsAntiClockwise

R/O - bool - true if arc is anticlockwise (same as .IsCCW)

.IsCCW

R/O - bool - true if arc is counter clockwise (same as . IsAntiClockwise)

.IsClockwise

R/O - bool - true if arc is clockwise (same as . IsCW )

.IsCW

R/O - bool - true if arc is clockwise (same as . IsClockwise)

Methods

:ArcMidPoint()

Returns a Point3D holding the mid point of the arc

:RadiusAndCentre(Point3D ret_centre_pt)

Calculate the centre point of the arc and the radius. The method returns the radius and also sets the position of the passed point to the centre point position of the arc. ret_centre_pt - Point3D - returned 3d position for centre point of arc (not mid-point)

Example Code

 local arc = ArcSpan(Point3D(0,0,0), Point3D(1,0,0), 1.0)
 local centre = Point3D()
 local radius = arc:RadiusAndCentre(centre)
 MessageBox("Arc Radius = " .. radius ..
 " Centre Point = " .. centre.x .. "," .. centre.y ) 


:SetBulge(bulge)

Set the bulge factor for this arc Bulge - double - bulge factor for arc

---

Global helper methods

ArcBulgeFromMidPoint(Point2D start, Point2D end, Point2D mid)

Return the bulge factor for an arc through the specified 3 points
start -Point2D -Start point for arc
end -Point2D -End point for arc
mid -Point2D -mid point for arc ( NOT centre point)
Back.jpg

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