Geom class provides static helper functions for basic geometric operations.
Given an anchor Pt, rebase all Pts in this group either to or from this anchor base.
a Group or an Iterable
an index for the Pt array, or an external Pt
a string either "to" (subtract all Pt with this anchor base), or "from" (add all Pt from this anchor base)
Bound an angle between 0 to 360 degrees.
angle value
Get a bounding box for a set of Pts.
a Group or an Iterable
a Group of two Pts, representing the top-left and bottom-right corners
Bound a radian between 0 to two PI.
radian value
Get a centroid (the average middle point) for a set of Pts.
a Group or an Iterable
a centroid Pt
Generate a cosine lookup table.
an object with a cosine tables (array of 360 values) and a function to get cosine given a radian input.
Get an interpolated (or extrapolated) value between two Pts. For linear interpolation between 2 scalar values, use Num.lerp
.
first Pt
second Pt
a value between 0 to 1 to interpolate, or any other value to extrapolate
interpolated point as a new Pt
Check if two Pts are perpendicular to each other (2D only).
Find two Pts that are perpendicular to this Pt (2D only).
a string such as "xy" (use Const.xy) or an array to specify index for two dimensions
an array of two Pt that are perpendicular to this Pt
Reflect a Pt or a Group of Pts along a 2D line. You may also use Pt.reflect2D
instance method.
either a single Pt, or a Group or an Iterable
a Group or an Iterable
optional axis such as "xy" (use Const.xy) to define a 2D plane, or a number array to specify indices
Rotate a Pt or a Group of Pts in 2D space. You may also use Pt.rotate2D
instance method.
either a single Pt, or a Group or an Iterable
rotate angle
optional anchor point to rotate from
optional axis such as "xy" (use Const.xy) to define a 2D plane, or a number array to specify indices
Scale a Pt or a Group of Pts. You may also use Pt.scale
instance method.
either a single Pt, or a Group or an Iterable
scale value
optional anchor point to scale from
Shear a Pt or a Group of Pts in 2D space. You may also use Pt.shear2D
instance method.
either a single Pt, or a Group or an Iterable
shearing value which can be a number or an array of 2 numbers
optional anchor point to shear from
optional axis such as "xy" (use Const.xy) to define a 2D plane, or a number array to specify indices
Generate a sine lookup table.
an object with a sine tables (array of 360 values) and a function to get sine value given a radian input.
Sort the Pts so that their edges will form a non-overlapping polygon. (Reference)
a Group or an Iterable
Convert an angle in radian to degree.
radian value
Convert an angle in degree to radian.
angle value
Check if a Pt is within the rectangular boundary defined by two Pts.
the Pt to check
boundary Pt 1
boundary Pt 2