Style Functions
Constraint Functions
equal
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
lessThan
Require that the value x
is less than the value y
with optional padding padding
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
padding | ℝ | Real Number | Padding |
greaterThan
Require that the value x
is greater than the value y
with optional padding padding
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
padding | ℝ | Real Number | Padding |
lessThanSq
Require that the value x
is less than the value y
, with steeper penalty
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
greaterThanSq
Require that the value x
is greater than the value y
, with steeper penalty
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
inRange
Require that the value x
is in the range defined by [x0, x1]
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | Value |
x0 | ℝ | Real Number | Lower bound |
x1 | ℝ | Real Number | Upper bound |
contains1D
Require that an interval [l1, r1]
contains another interval [l2, r2]
. If not possible, returns 0.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
[l1, r1] | ℝ² | 2d Vector of Reals | First interval |
[l2, r2] | ℝ² | 2d Vector of Reals | Second interval |
disjointScalar
Make scalar c
disjoint from a range left, right
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ | Real Number | Scalar |
left | ℝ | Real Number | Left bound |
right | ℝ | Real Number | Right bound |
perpendicular
Require that the vector defined by (q, p)
is perpendicular from the vector defined by (r, p)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
q | ℝⁿ | Vector of Reals | First point |
p | ℝⁿ | Vector of Reals | Second point |
r | ℝⁿ | Vector of Reals | Third point |
collinear
Require that three points be collinear. This does not enforce a specific ordering of points, instead it takes the arrangement of points that is most easily satisfiable.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝⁿ | Vector of Reals | First point |
c2 | ℝⁿ | Vector of Reals | Second point |
c3 | ℝⁿ | Vector of Reals | Third point |
collinearOrdered
Require that three points be collinear and enforces the order of these points as provided.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝⁿ | Vector of Reals | First point |
c2 | ℝⁿ | Vector of Reals | Second point |
c3 | ℝⁿ | Vector of Reals | Third point |
onCanvas
Require that shape
is on the canvas
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shape | Shape | Any Shape | Shape |
canvasWidth | ℝ | Real Number | Width of canvas |
canvasHeight | ℝ | Real Number | Height of canvas |
overlapping
Require that shape s1
overlaps shape s2
with some overlap overlap
.
based on the type of the shape, and with an optional overlap
between them
(e.g. if s1
should be overlapping s2
with margin overlap
).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | Shape 1 |
s2 | Shape | Any Shape | Shape 2 |
overlap | ℝ | Real Number | Overlap |
overlappingEllipses
Require that ellipse e1
overlaps with ellipse e2
with some overlap overlap
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝ² | 2d Vector of Reals | Center of |
rx1 | ℝ | Real Number | Horizontal radius of |
ry1 | ℝ | Real Number | Vertical radius of |
c2 | ℝ² | 2d Vector of Reals | Center of |
rx2 | ℝ | Real Number | Horizontal radius of |
ry2 | ℝ | Real Number | Vertical radius of |
overlap | ℝ | Real Number | the least amount of overlap |
overlappingCircleEllipse
Require that circle c
overlaps with ellipse e
with some overlap overlap
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝ² | 2d Vector of Reals | Center of |
r1 | ℝ | Real Number | Radius of |
c2 | ℝ² | 2d Vector of Reals | Center of |
rx2 | ℝ | Real Number | Horizontal radius of |
ry2 | ℝ | Real Number | Vertical radius of |
overlap | ℝ | Real Number | the least amount of overlap |
disjoint
Require that a shape s1
is disjoint from shape s2
, based on the type of the shape, and with an optional padding
between them (e.g. if s1
should be disjoint from s2
with margin padding
).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | Shape 1 |
s2 | Shape | Any Shape | Shape 2 |
padding | ℝ | Real Number | Padding |
touching
Require that shape s1
is touching shape s2
based on the type of the shape, and with an optional padding
between them (e.g. if s1
should be touching s2
with margin padding
).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | Shape 1 |
s2 | Shape | Any Shape | Shape 2 |
padding | ℝ | Real Number | Padding |
contains
Require that a shape s1
contains another shape s2
, based on the type of the shape, and with an optional padding
between the sizes of the shapes (e.g. if s1
should contain s2
with margin padding
).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | Shape 1 |
s2 | Shape | Any Shape | Shape 2 |
padding | ℝ | Real Number | Padding |
containsCircles
Require that a circle c1
contains another circle c2
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝ² | 2d Vector of Reals | Center of |
r1 | ℝ | Real Number | Radius of |
c2 | ℝ² | 2d Vector of Reals | Center of |
r2 | ℝ | Real Number | Radius of |
padding | ℝ | Real Number | Margin between the circles |
containsPolys
Require that a polygon p1
contains another polygon p2
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts1 | (ℝ²)ⁿ | List of 2d Real Vectors | List of points for |
pts2 | (ℝ²)ⁿ | List of 2d Real Vectors | List of points for |
padding | ℝ | Real Number | Margin between the polygons |
containsPolyCircle
Require that a polygon p
contains circle c
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points for |
c | ℝ² | 2d Vector of Reals | Center of |
r | ℝ | Real Number | Radius of |
padding | ℝ | Real Number | Margin between the polygon and the circle |
containsPolyPoint
Require that a polygon p
contains point pt
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points for polygon |
pt | ℝ² | 2d Vector of Reals | Location of point |
padding | ℝ | Real Number | Margin between the polygon and the point |
containsCirclePoint
Require that a circle c
contains point pt
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | Center of |
r | ℝ | Real Number | Radius of |
pt | ℝ² | 2d Vector of Reals | Location of point |
padding | ℝ | Real Number | Margin between the polygon and the point |
containsCirclePoly
Require that a circle c
contains polygon p
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | Center of |
r | ℝ | Real Number | Radius of |
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points for polygon |
padding | ℝ | Real Number | Margin between the polygon and the point |
containsCircleRect
Require that a circle c
contains rectangle r
with optional padding padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | Center of |
r | ℝ | Real Number | Radius of |
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of rectangle |
padding | ℝ | Real Number | Margin between the polygon and the point |
containsRectCircle
Require that a rectangle r
contains a circle c
with optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of rectangle |
c | ℝ² | 2d Vector of Reals | Center of |
r | ℝ | Real Number | Radius of |
padding | ℝ | Real Number | Margin between the polygon and the point |
containsRects
Requires that rect1
contains rect2
with some optional margin padding
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect1 | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of rectangle |
rect2 | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) points of rectangle |
padding | ℝ | Real Number | Margin between the polygon and the point |
distributeHorizontally
Requires that the bounding boxes for shapes within a shapeList are evenly spaced horizontally with a set padding.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
shapes | Shape[] | List of shapes | List containing the top-left, top-right, bottom-right, bottom-left points (in that order) of the axis-aligned bounding box of a shape | |
padding | ℝ | Real Number | Margin between bounding boxes of shapes | 0 |
leftToRight | true | false | Boolean Value |
| true |
distributeVertically
Requires that the bounding boxes for shapes within a shapeList are evenly spaced vertically with a set padding.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
shapes | Shape[] | List of shapes | List containing the top-left, top-right, bottom-right, bottom-left points (in that order) of the axis-aligned bounding box of a shape | |
padding | ℝ | Real Number | Margin between bounding boxes of shapes | 0 |
topToBottom | true | false | Boolean Value |
| true |
disjointIntervals
Make two intervals disjoint. They must be 1D intervals (line-like shapes) sharing a y-coordinate.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | Line 1 |
s2 | LineShape | Line Shape | Line 2 |
isLocallyConvex
The shape should be locally convex (all angles between consecutive edges would have the same sign)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
isConvex
The enclosed area should be convex
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
isEquilateral
All edges should have the same length
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
isEquiangular
All angles between consecutive edges should be equal
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
Objective Functions
minimal
Encourage the input value to be close to negative infinity
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | Value |
maximal
Encourage the input value to be close to infinity
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | Value |
equal
Encourage the inputs to have the same value: (x - y)^2
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
nearVec
Encourage two vectors v1
and v2
to be near each other with distance offset
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v1 | ℝⁿ | Vector of Reals | a vector |
v2 | ℝⁿ | Vector of Reals | a vector |
offset | ℝ | Real Number | distance between two vectors |
greaterThan
Encourage x to be greater than or equal to y: max(0,y - x)^2
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
lessThan
Encourage x to be less than or equal to y: max(0,x - y)^2
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | First value |
y | ℝ | Real Number | Second value |
repelPt
Repel point a
from another scalar b
with weight weight
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
weight | ℝ | Real Number | Weight |
a | ℝⁿ | Vector of Reals | First point |
b | ℝⁿ | Vector of Reals | Second point |
repelScalar
Repel scalar c
from another scalar d
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ | Real Number | First scalar |
d | ℝ | Real Number | Second scalar |
inDirection
Encourage the point p
to be in the direction direction
with respect to point pRef
. The direction
vector does not need to be normalized. The offset
parameter is the shortest allowed distance between the points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝ² | 2d Vector of Reals | |
pRef | ℝ² | 2d Vector of Reals | |
direction | ℝ² | 2d Vector of Reals | |
offset | ℝ | Real Number |
below
Encourage the center of bottom
to be below the center of top
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
bottom | Shape | Any Shape | shape on the bottom | |
top | Shape | Any Shape | shape on the top | |
offset | ℝ | Real Number | distance between the two centers | 100 |
above
Encourage the center of top
to be above the center of bottom
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
top | Shape | Any Shape | shape on the top | |
bottom | Shape | Any Shape | shape on the bottom | |
offset | ℝ | Real Number | distance between the two centers | 100 |
leftwards
Encourage the center of left
to be leftwards to the center of right
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
left | Shape | Any Shape | shape on the left | |
right | Shape | Any Shape | shape on the right | |
offset | ℝ | Real Number | distance between the two centers | 100 |
rightwards
Encourage the center of right
to be rightwards to the center of left
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
right | Shape | Any Shape | shape on the right | |
left | Shape | Any Shape | shape on the left | |
offset | ℝ | Real Number | distance between the two centers | 100 |
sameCenter
Encourage shape s1
to have the same center position as shape s2
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | a shape |
s2 | Shape | Any Shape | a shape |
notTooClose
Try to repel shapes s1
and s2
with some weight.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
s1 | Shape | Any Shape | a shape | |
s2 | Shape | Any Shape | a shape | |
weight | ℝ | Real Number | weight of repel | 10 |
near
Try to place shape s1
near shape s2
(putting their centers at the same place).
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
s1 | Shape | Any Shape | a shape | |
s2 | Shape | Any Shape | a shape | |
offset | ℝ | Real Number | offset | 10 |
nearPt
Try to place shape s1
near a location (x, y)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | a shape |
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
nonDegenerateAngle
Try to place shape s1
near a location (x, y)
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
s0 | Shape | Any Shape | a shape | |
s1 | Shape | Any Shape | a shape | |
s2 | Shape | Any Shape | a shape | |
strength | ℝ | Real Number | strength | 20 |
range | ℝ | Real Number | range | 10 |
centerLabelAbove
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | |
s2 | EquationShape | ImageShape | RectangleShape | TextShape | any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape | |
w | ℝ | Real Number |
centerLabel
Try to center a label s2
with respect to some shape s1
.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
s1 | LineShape | EquationShape | ImageShape | RectangleShape | TextShape | any of: Line Shape, or any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape | ||
s2 | EquationShape | ImageShape | RectangleShape | TextShape | any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape | ||
w | ℝ | Real Number | ||
padding | ℝ | Real Number | 10 |
pointLineDist
Try to make distance between a point and a segment s1
equal to padding.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
point | ℝ² | 2d Vector of Reals | |
s1 | LineShape | Line Shape | |
padding | ℝ | Real Number |
isRegular
Try to make the shape regular
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
isEquilateral
Try to make the shape equilateral
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
isEquiangular
Try to make the shape equiangular
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
Computation Functions
makePath
See https://github.com/penrose/penrose/issues/716
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | Start point of the path |
end | ℝ² | 2d Vector of Reals | End point of the path |
curveHeight | ℝ | Real Number | Height of the curve |
padding | ℝ | Real Number | Padding between the curve and the labels |
Returns: PathCmd (Path Command)
get
Return i
th element of list `xs, assuming lists only hold floats.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals | List of floats |
i | ℕ | Natural Number | Index of the element to return |
Returns: ℝ (Real Number)
rgba
Return a paint color of elements r
, g
, b
, a
(red, green, blue, opacity).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
r | [0,1] | Real Number in Unit Interval | Red |
g | [0,1] | Real Number in Unit Interval | Green |
b | [0,1] | Real Number in Unit Interval | Blue |
a | [0,1] | Real Number in Unit Interval | Opacity |
Returns: Color (Color)
selectColor
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
color1 | Color | Color | First color |
color2 | Color | Color | Second color |
level | ℝ | Real Number | Level |
Returns: Color (Color)
hsva
Return a paint color of elements h
, s
, v
, a
(hue, saturation, value, opacity).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
h | ℝ | Real Number | Hue in [0, 360) |
s | ℝ | Real Number | Saturation in [0, 100] |
v | ℝ | Real Number | Value in [0, 100] |
a | [0,1] | Real Number in Unit Interval | Opacity |
Returns: Color (Color)
oneBasedElement
Index a point list using 1-based indexing.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | list of points |
i | ℤ⁺ | Positive Integer | 1-based index |
Returns: ℝ² (2d Vector of Reals)
acosh
Return acosh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
acos
Return acos(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
asin
Return asin(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
asinh
Return asinh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
mod
Return mod(a, n)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a | ℝ | Real Number |
|
n | ℝ | Real Number |
|
Returns: ℝ (Real Number)
atan
Return atan(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
atan2
Return atan2(x, y)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
Returns: ℝ (Real Number)
atanh
Return atanh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
cbrt
Return cbrt(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
ceil
Return ceil(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
cos
Return cos(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
cosh
Return cosh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
exp
Return exp(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
expm1
Return expm1(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
floor
Return floor(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
log
Return log(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
log2
Return log2(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
log10
Return log10(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
log1p
Return log1p(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
pow
Return pow(x, y)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
Returns: ℝ (Real Number)
round
Return round(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
sign
Return sign(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
sin
Return sin(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
sinh
Return sinh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
tan
Return tan(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
tanh
Return tanh(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
trunc
Return trunc(x)
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
sum
Return the sum of elements in a vector.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals | elements |
Returns: ℝ (Real Number)
sumVectors
Return the sum of vectors in a list of vectors.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
vecs | (ℝⁿ)ᵐ | List of Real Vectors | vectors |
Returns: ℝⁿ (Vector of Reals)
maxList
Return the maximum of the elements in a vector.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals | elements |
Returns: ℝ (Real Number)
minList
Return the minimum of the elements in a vector.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals | elements |
Returns: ℝ (Real Number)
count
Return the number of the elements in a vector.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals | elements |
Returns: ℝ (Real Number)
dot
Return the dot product of v
and w
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | Vector |
w | ℝⁿ | Vector of Reals | Vector |
Returns: ℝ (Real Number)
identity
identity(n)
returns the identity matrix
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
n | ℤ⁺ | Positive Integer | dimension |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
diagonal
diagonal(v)
takes a vector of length , and returns the diagonal matrix
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | vector of diagonal entries |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
trace
trace(A)
takes a square matrix , and returns the trace , equal to the sum of its diagonal entries.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
A | (ℝⁿ)ᵐ | List of Real Vectors | a square matrix |
Returns: ℝ (Real Number)
determinant
determinant(A)
takes a , , or matrix , and returns its determinant .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
A | (ℝⁿ)ᵐ | List of Real Vectors | a square matrix |
Returns: ℝ (Real Number)
inverse
inverse(A)
takes a , , or matrix , and returns its inverse . If the matrix is not invertible, the result may be numerically invalid (with INF
or NaN
entries).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
A | (ℝⁿ)ᵐ | List of Real Vectors | a 2x2, 3x3, or 4x4 matrix |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
outerProduct
outerProduct(u,v)
takes two vectors , of equal length , and returns the outer product matrix , with entries .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | Vector |
w | ℝⁿ | Vector of Reals | Vector |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
crossProductMatrix
crossProductMatrix(v)
takes a 3-vector , and returns a skew symmetric matrix such that for any vector .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | Vector |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
matrix
matrix(a,b,c,d,e,f)
specifies a transformation matrix
This function mirrors the SVG/CSS matrix
transform function.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a | ℝ | Real Number | top left entry |
b | ℝ | Real Number | middle left entry |
c | ℝ | Real Number | top center entry |
d | ℝ | Real Number | middle center entry |
e | ℝ | Real Number | top right entry |
f | ℝ | Real Number | middle right entry |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
matrix3d
matrix(a1, a2, a3, a4, b1, b2, b3, b4, c1, c2, c3, c4, d1, d2, d3, d4)
specifies a transformation matrix
This function mirrors the CSS matrix3d
transform function.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a1 | ℝ | Real Number | 1st column of 1st row |
b1 | ℝ | Real Number | 1st column of 2nd row |
c1 | ℝ | Real Number | 1st column of 3rd row |
d1 | ℝ | Real Number | 1st column of 4th row |
a2 | ℝ | Real Number | 2nd column of 1st row |
b2 | ℝ | Real Number | 2nd column of 2nd row |
c2 | ℝ | Real Number | 2nd column of 3rd row |
d2 | ℝ | Real Number | 2nd column of 4th row |
a3 | ℝ | Real Number | 3rd column of 1st row |
b3 | ℝ | Real Number | 3rd column of 2nd row |
c3 | ℝ | Real Number | 3rd column of 3rd row |
d3 | ℝ | Real Number | 3rd column of 4th row |
a4 | ℝ | Real Number | 4th column of 1st row |
b4 | ℝ | Real Number | 4th column of 2nd row |
c4 | ℝ | Real Number | 4th column of 3rd row |
d4 | ℝ | Real Number | 4th column of 4th row |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
rotate
rotate(theta, [x], [y])
returns a counter-clockwise 2D rotation by an angle , optionally around the point . If no point is specified, the rotation is around the origin. Since this transformation is in general an affine transformation, it is encoded in homogeneous coordinates via the matrix
For the linear version, see rotate2d()
.)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number | angle of rotation (in radians) |
x | ℝ | Real Number | center of rotation (x coordinate) |
y | ℝ | Real Number | center of rotation (y coordinate) |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
rotate2d
rotate2d(theta)
returns a 2D rotation around the origin by a given angle , encoded via the matrix
This matrix cannot directly be composed with 2D affine transformations; for the affine version, see rotate()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number | angle of rotation (in radians) |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
rotate3d
rotate3d(theta, v)
returns a 3D rotation by an angle around a unit axis . The matrix is constructed via Rodrigues' rotation formula
where is the identity matrix, and is the cross product matrix associated with (see crossProductMatrix()
). This matrix cannot directly be composed with 3D affine transformations; for the affine version, see rotate3dh()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number | angle of rotation (in radians) |
v | ℝⁿ | Vector of Reals | axis of rotation (unit vector) |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
rotate3dh
rotate3dh(theta, v)
returns a 3D rotation by a given angle around a unit axis . This transformation is encoded as a matrix in homogeneous coordinates, so that it can be composed with 3D affine transformations. For the linear version, see rotate3d()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number | angle of rotation (in radians) |
v | ℝⁿ | Vector of Reals | axis of rotation (unit vector) |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
scale
scale(sx, sy)
returns a nonuniform scaling by factors , along , axes, encoded via the matrix
This transformation is encoded as a matrix in homogeneous coordinates, so that it can be composed with 2D affine transformations. For the linear version, see scale2d()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
sx | ℝ | Real Number | horizontal scale factor |
sy | ℝ | Real Number | vertical scale factor |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
scale2d
scale2d(sx,sy)
returns a matrix representing nonuniform scaling by factors , along , axes, encoded via the matrix
This transformation is encoded as a matrix that cannot directly be composed with 2D affine transformations. For the affine version, see rotate()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
sx | ℝ | Real Number | horizontal scale factor |
sy | ℝ | Real Number | vertical scale factor |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
scale3d
scale3d(sx, sy, sz)
returns a nonuniform scaling by factors , , along , , axes, via the matrix
This transformation is encoded as a matrix that cannot directly be composed with 3D affine transformations. For the affine version, see scale3dh()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
sx | ℝ | Real Number | x scale factor |
sy | ℝ | Real Number | y scale factor |
sz | ℝ | Real Number | z scale factor |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
scale3dh
scale3dh(sx, sy, sz)
returns a matrix representing nonuniform scaling by factors , , along , , axes, via the matrix
This transformation is encoded as a matrix in homogeneous coordinates, so that it can be composed with 3D affine transformations. For the linear version, see scale3D()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
sx | ℝ | Real Number | x scale factor |
sy | ℝ | Real Number | y scale factor |
sz | ℝ | Real Number | z scale factor |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
skew
skew(a_x, a_y)
takes angles and , and returns a 2D skew transformation encoded by the matrix
If is not defined, its default value is 0, resulting in a purely horizontal skewing. This transformation is encoded as a matrix in homogeneous coordinates, so that it can be composed with affine transformations. For the linear version, see skew2d()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
ax | ℝ | Real Number | horizontal angle |
ay | ℝ | Real Number | vertical angle |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
skew2d
skew2d(a_x, a_y)
takes angles and , and returns a 2D skew transformation encoded via the matrix
If is not defined, its default value is 0, resulting in a purely horizontal skewing. This transformation is encoded as a matrix that cannot directly be composed with 2D affine transformations. For the affine version, see skew()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
ax | ℝ | Real Number | horizontal angle |
ay | ℝ | Real Number | vertical angle |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
shear
shear(u,v)
takes two -dimensional vectors and , and returns a transformation that shears any given point in the direction according to its extent along the direction , i.e., that performs the transformation
This transformation is encoded as an matrix in homogeneous coordinates, so that it can be composed with affine transformations. For the linear version, see shear2d()
or shear3d()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝⁿ | Vector of Reals | offset direction |
v | ℝⁿ | Vector of Reals | shear axis |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
shear2d
shear2d(u,v)
takes two 2-dimensional vectors and , and returns a transformation that shears any given point in the direction according to its extent along the direction , i.e., that performs the transformation
This transformation is encoded as a matrix that cannot directly be composed with 2-dimensional affine transformations. For the affine version, see shear()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝⁿ | Vector of Reals | offset direction |
v | ℝⁿ | Vector of Reals | shear axis |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
shear3d
shear3d(u,v)
takes two 3-dimensional vectors and , returns a transformation that shears any given point in the direction according to its extent along the direction , i.e., that performs the transformation
This transformation is encoded as a matrix that cannot directly be composed with 3-dimensional affine transformations. For the affine version, see shear()
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝⁿ | Vector of Reals | offset direction |
v | ℝⁿ | Vector of Reals | shear axis |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
translate
translate(x,y)
returns a translation by the given offset . If is not specified, it is assumed to be . Since translation is affine rather than linear, it is encoded as a matrix in homogeneous coordinates, namely
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | horizontal offset |
y | ℝ | Real Number | vertical offset |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
translate3dh
translate3dh(x,y,z)
returns a translation by . Since translation is affine rather than linear, it is encoded as a matrix in homogeneous coordinates, namely
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number | x offset |
y | ℝ | Real Number | y offset |
z | ℝ | Real Number | z offset |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
lookAt
lookAt(eye, center, up)
returns a viewing matrix derived from an eye point , a reference point indicating the center of the scene, and an up vector . The matrix maps the reference point to the negative z axis and the eye point to the origin. When a typical projection matrix is used, the center of the scene therefore maps to the center of the viewport. Similarly, the direction described by the up vector projected onto the viewing plane is mapped to the positive y axis so that it points upward in the viewport. The up vector must not be parallel to the line of sight from the eye point to the reference point. The matrix is given explicitly by where is a translation by (a la translate3dh
), and is given by
where is the unit vector from the eye to the center, is a vector pointing to the side, and is a vector in roughly the same direction as that completes an orthonormal basis with and (hence, is a rotation matrix).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
eye | ℝⁿ | Vector of Reals | position of the eye point |
center | ℝⁿ | Vector of Reals | position of the reference point |
up | ℝⁿ | Vector of Reals | unit vector in the upward direction |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
perspective
perspective(fovy, aspect, [zNear], [zFar])
returns a perspective projection matrix, given a vertical field of view , an aspect ratio , and optional near/far -values, and . The aspect ratio should match the aspect ratio of the associated viewport. For example, an aspect ratio of 2 means the viewer's angle of view is twice as wide in as it is in . Coordinates within will get mapped to depth values in the range . Letting , the perspective matrix is given by
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
fovy | ℝ | Real Number | field of view angle, in degrees, in the y direction | |
aspect | ℝ | Real Number | aspect ratio that determines the field of view in the x direction, equal to the ratio of x (width) to y (height) | |
zNear | ℝ | Real Number | distance from the viewer to the near clipping plane (always positive), with a default value of 0.1 | 0.1 |
zFar | ℝ | Real Number | distance from the viewer to the far clipping plane (always positive), with a default value of 100.0 | 100 |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
ortho
ortho(left, right, bottom, top, [zNear], [zFar])
returns a transformation that produces a parallel projection, given four horizontal/vertical clipping planes, and an optional near/far clipping plane. Letting , , , and denote the left/right/bottom/top clipping planes, respectively, the projection matrix is given by
where
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
Left | ℝ | Real Number | coordinate of the left vertical clipping plane | |
Right | ℝ | Real Number | coordinate of the right vertical clipping plane | |
Bottom | ℝ | Real Number | coordinate of the bottom horizontal clipping plane | |
Top | ℝ | Real Number | coordinate of the top horizontal clipping plane | |
zNear | ℝ | Real Number | distance to the nearer depth clipping plane (negative if the plane is behind the viewer), with a default value of 0.1 | 0.1 |
zFar | ℝ | Real Number | distance to the farther depth clipping plane (negative if the plane is behind the viewer), with a default value of 100 | 100 |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
project
project(p, model, proj, view)
transforms the specified 3D object coordinates into 2D window coordinates using a given model transformation , projection transformation , and viewport , where , give the lower-left corner of the canvas, and , are its width and height. To also recover the depth, see projectDepth()
. The projection is performed by first computing , where are the homogeneous coordinates for . The first two components of (where is the final component of ) gives coordinates in the range , which are then stretched to the range .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝⁿ | Vector of Reals | 3D object coordinates (x,y,z) |
model | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 modelview matrix |
proj | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 projection matrix |
view | ℝⁿ | Vector of Reals | viewport (x, y, width, height) |
Returns: ℝⁿ (Vector of Reals)
projectDepth
projectDepth(p, model, proj, view)
transforms the specified 3D object coordinates into 2D window coordinates using a given model transformation , projection transformation , and viewport , where , give the lower-left corner of the canvas, and , are its width and height. It returns the projected coordinates, as well as the depth relative to the view. See project()
for further information.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝⁿ | Vector of Reals | 3D object coordinates (x,y,z) |
model | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 modelview matrix |
proj | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 projection matrix |
view | ℝⁿ | Vector of Reals | viewport (x, y, width, height) |
Returns: ℝⁿ (Vector of Reals)
projectList
projectList(P, model, proj, view)
transforms a list of 3D object coordinates into window 2D coordinates using a given model transformation , projection transformation , and viewport , where , give the lower-left corner of the canvas, and , are its width and height. Returns the list of projected 2D coordinates . See project()
for further information.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | (ℝⁿ)ᵐ | List of Real Vectors | list of 3D object coordinates (x,y,z) |
model | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 modelview matrix |
proj | (ℝⁿ)ᵐ | List of Real Vectors | 4x4 projection matrix |
view | ℝⁿ | Vector of Reals | viewport (x, y, width, height) |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
matrixMultiplyList
matrixMultiplyList(A, V)
multiplies each vector in the list by the given matrix , returning the list of products. List elements must all be vectors of length .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
A | (ℝⁿ)ᵐ | List of Real Vectors |
|
V | (ℝⁿ)ᵐ | List of Real Vectors | list of |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
fromHomogeneous
fromHomogeneous(q)
takes a vector of length , encoding a point in -dimensional homogeneous coordinates, and returns a vector of length , encoding the same point in Cartesian coordinates, i.e,. .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
q | ℝⁿ | Vector of Reals | homogeneous coordinates |
Returns: ℝⁿ (Vector of Reals)
fromHomogeneousList
fromHomogeneousList(Q)
takes a list of vectors of length , encoding points in -dimensional homogeneous coordinates, and returns a list of vectors of length , encoding the same points in Cartesian coordinates.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
Q | (ℝⁿ)ᵐ | List of Real Vectors | list of points in homogeneous coordinates |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
toHomogeneous
toHomogeneous(p)
takes a vector of length , encoding a point in -dimensional Cartesian coordinates, and returns a vector of length , encoding the same point in homogeneous coordinates, i.e., .
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝⁿ | Vector of Reals | Cartesian coordinates |
Returns: ℝⁿ (Vector of Reals)
toHomogeneousList
toHomogeneousList(P)
takes a list of vectors of length , encoding points in -dimensional Cartesian coordinates, and returns a list of vectors of length , encoding the same points in homogeneous coordinates.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
P | (ℝⁿ)ᵐ | List of Real Vectors | list of points in Cartesian coordinates |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
toHomogeneousMatrix
toHomogeneousMatrix(A)
takes a square matrix representing a spatial transformation in dimensions, and returns an matrix representing the same transformation in homogeneous coordinates.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
A | (ℝⁿ)ᵐ | List of Real Vectors | matrix encoding linear transformation |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
length
Return the length of the Line shape.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
l | LineShape | Line Shape | A line |
Returns: ℝ (Real Number)
normalize
Return the normalized version of vector v
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | Vector |
Returns: ℝⁿ (Vector of Reals)
pathFromPoints
Given a list of points pts
, returns a PathData
that can be used as input to the Path
shape's pathData
attribute to be drawn on the screen.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | Path Type |
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points |
Returns: PathCmd (Path Command)
quadraticCurveFromPoints
Given a list of points pts
, returns a PathData
that can be used as input to the Path
shape's pathData
attribute to be drawn on the screen.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | Path Type |
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points |
Returns: PathCmd (Path Command)
interpolateQuadraticFromPoints
Draw a curve interpolating three given points. (Note that this is different from specifying the three control points of a quadratic Bézier curve, since a Bézier does not interpolate the middle control point.)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | Path Type |
p0 | ℝ² | 2d Vector of Reals | First point |
p1 | ℝ² | 2d Vector of Reals | Second point |
p2 | ℝ² | 2d Vector of Reals | Third point |
Returns: PathCmd (Path Command)
cubicCurveFromPoints
Given a list of points pts
, returns a PathData
that can be used as input to the Path
shape's pathData
attribute to be drawn on the screen.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | Path type |
pts | (ℝ²)ⁿ | List of 2d Real Vectors | List of points |
Returns: PathCmd (Path Command)
connectPaths
Given a list of PathData
s, returns a PathData
representing the union of these paths with lines connecting the start and end points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | Path type |
pathDataList | PathData[] | List of paths | List of path data |
Returns: PathCmd (Path Command)
concatenatePaths
Given a list of PathData
s, return the union of these paths.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathDataList | PathData[] | List of paths | List of path data |
Returns: PathCmd (Path Command)
joinPaths
Given a list of PathData
s, join them into one SVG path. For correct results, the end points and start pointsof each path must already coincide.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathDataList | PathData[] | List of paths | List of path data |
Returns: PathCmd (Path Command)
Penrose
Return path data describing an "impossible polygon."
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
center | ℝⁿ | Vector of Reals | (x,y) translation | [ 0, 0 ] |
radius | ℝ | Real Number | radius of outer polygon (must be positive) | 50 |
holeSize | ℝ | Real Number | radius of inner polygon as a fraction of the outer radius (in range (0,1]) | 0.35 |
angle | ℝ | Real Number | angle of rotation | 0 |
nSides | ℤ⁺ | Positive Integer | number of sides (integer ≥ 3) | 5 |
chirality | String | String | either "cw" for clockwise, or "ccw" for counterclockwise | ccw |
Returns: PathCmd (Path Command)
firstPoint
Returns the first point in a list.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | list of points |
Returns: ℝ² (2d Vector of Reals)
lastPoint
Returns the last point in a list.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | list of points |
Returns: ℝ² (2d Vector of Reals)
averagePoint
Returns the average (mean) of all points in a list.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | list of points |
Returns: ℝⁿ (Vector of Reals)
interpolatingSpline
Returns path data for a curve that smoothly interpolates the given points. Interpolation is performed via a Catmull-Rom spline.
Parameters:
Name | Type | Type Description | Description | Default Value |
---|---|---|---|---|
pathType | "open" | "closed" | Path Type | either "open" or "closed." | |
points | (ℝⁿ)ᵐ | List of Real Vectors | points to be interpolated | |
tension | ℝ | Real Number | smoothness of curve (0=piecewise linear, .25=default) | 0.25 |
Returns: PathCmd (Path Command)
diffusionProcess
Return n
points sampled from a diffusion process starting at X0
, with covariance matrix A
and constant drift omega
. This path approximately integrates the stochastic differential equation dX_t = omega dt + A dW_t, where W_t is a Wiener process.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
n | ℤ⁺ | Positive Integer | number of points |
X0 | ℝ² | 2d Vector of Reals | starting location |
A | (ℝⁿ)ᵐ | List of Real Vectors | covariance matrix |
omega | ℝ² | 2d Vector of Reals | drift direction |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
unitMark
Return two points parallel to line s1
using its normal line s2
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | |
s2 | LineShape | Line Shape | |
padding | ℝ | Real Number |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
unitMark2
Return two points to "cap off" the line made in unitMark
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
[start, end] | (ℝ²)ⁿ | List of 2d Real Vectors | |
t | String | String | |
size | ℝ | Real Number |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
arc
Return series of elements that can render an arc SVG. See: https://css-tricks.com/svg-path-syntax-illustrated-guide/ for the "A" spec. Returns elements that can be passed to Path shape spec to render an SVG arc.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | The path type: either "open" or "closed." whether the SVG should automatically draw a line between the final point and the start point |
start | ℝ² | 2d Vector of Reals | coordinate to start drawing the arc |
end | ℝ² | 2d Vector of Reals | coordinate to finish drawing the arc |
[width, height] | ℝ² | 2d Vector of Reals | width and height of the ellipse to draw the arc along |
rotation | ℝ | Real Number | angle in degrees to rotate ellipse about its center |
largeArc | ℝ | Real Number | 0 to draw shorter of 2 arcs, 1 to draw longer |
arcSweep | ℝ | Real Number | 0 to rotate CCW, 1 to rotate CW |
Returns: PathCmd (Path Command)
circularArc
Return path data that describes a circular arc. The arc is equivalent to the parametric curve center + r*(cos(t),sin(t)) for t in the range [theta0,theta1]. More general arcs (e.g., along an ellipse) can be drawn using arc().
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pathType | "open" | "closed" | Path Type | The path type: either "open" or "closed." whether the SVG should automatically draw a line between the final point and the start point |
center | ℝ² | 2d Vector of Reals | circle center |
r | ℝ | Real Number | circle radius |
theta0 | ℝ | Real Number | start angle in radians |
theta1 | ℝ | Real Number | end angle in radians |
Returns: PathCmd (Path Command)
repeatedArcs
Generate multiple concentric arcs. Useful for denoting equal angles.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
innerStart | ℝ² | 2d Vector of Reals | coordinate to start drawing the inner arc |
innerEnd | ℝ² | 2d Vector of Reals | coordinate to end the inner arc |
outerStart | ℝ² | 2d Vector of Reals | coordinate to start drawing the outer arc |
outerEnd | ℝ² | 2d Vector of Reals | coordinate to end the outer arc |
innerRadius | ℝ² | 2d Vector of Reals | radii of the ellipse to draw the inner arc along (width, height) |
repeat | ℤ⁺ | Positive Integer | number of times to repeat the arc |
spacing | ℝ | Real Number | spacing between arcs |
arcSweep | ℝ | Real Number | arc length to sweep |
Returns: PathCmd (Path Command)
wedge
Return series of elements that render a "wedge", which is the same as the arc above except that it's connected to the circle center and filled. Returns elements that can be passed to Path shape spec to render an SVG arc.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
center | ℝ² | 2d Vector of Reals | center of the circle on which the arc sits |
start | ℝ² | 2d Vector of Reals | coordinate to start drawing the arc |
end | ℝ² | 2d Vector of Reals | coordinate to finish drawing the arc |
radius | ℝ² | 2d Vector of Reals | width and height of the ellipse to draw the arc along (i.e. [width, height]) |
rotation | ℝ | Real Number | angle in degrees to rotate ellipse about its center |
largeArc | ℝ | Real Number | 0 to draw shorter of 2 arcs, 1 to draw longer |
arcSweep | ℝ | Real Number | 0 to rotate CCW, 1 to rotate CW |
Returns: PathCmd (Path Command)
ptOnLine
Find the point that is located at dist r along a line between p1 and p2. Returns vector representation of the point of intersection.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p1 | ℝⁿ | Vector of Reals | start point of line segment |
p2 | ℝⁿ | Vector of Reals | endpoint of line segment |
r | ℝ | Real Number | distance from p1 to travel along the line |
Returns: ℝⁿ (Vector of Reals)
arcSweepFlag
Return 0 if direction of rotation is CCW, 1 if direction of rotation is CW.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
[x1, y1] | ℝ² | 2d Vector of Reals | x, y coordinates of the circle/ellipse that the arc is drawn on |
start | ℝ² | 2d Vector of Reals | start point of the arc |
end | ℝ² | 2d Vector of Reals | end point of the arc |
Returns: ℝ (Real Number)
angleBetween
Return the unsigned angle between vectors u, v
, in radians. Assumes that both u and v have nonzero magnitude. The returned value will be in the range [0,pi].
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝⁿ | Vector of Reals | A vector |
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
angleFrom
Return the signed angle from vector u
to vector v
, in radians. Assumes that both u and v are 2D vectors and have nonzero magnitude. The returned value will be in the range [-pi,pi].
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝⁿ | Vector of Reals | A vector |
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
cross2D
Return the 2D cross product of u
and v
, equal to the determinant of the 2x2 matrix [u v]
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝ² | 2d Vector of Reals | A vector |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
cross
Return the 3D cross product of 3D vectors u
and v
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
u | ℝ³ | 3d Vector of Reals | A vector |
v | ℝ³ | 3d Vector of Reals | A vector |
Returns: ℝ³ (3d Vector of Reals)
lineLineIntersection
Return the intersection of a line passing through a0
and a1
with a line passing through b0
and b1
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a0 | ℝ² | 2d Vector of Reals | First point of first line |
a1 | ℝ² | 2d Vector of Reals | Second point of first line |
b0 | ℝ² | 2d Vector of Reals | First point of second line |
b1 | ℝ² | 2d Vector of Reals | Second point of second line |
Returns: ℝ² (2d Vector of Reals)
midpoint
Return a point located at the midpoint between pts start
and end
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝⁿ | Vector of Reals | First point |
end | ℝⁿ | Vector of Reals | Second point |
Returns: ℝⁿ (Vector of Reals)
midpointOffset
Return a point located at the midpoint of a line s1
but offset by padding
in its normal direction (for labeling).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | A line |
padding | ℝ | Real Number | Padding between midpoint and label |
Returns: ℝ² (2d Vector of Reals)
chevron
Return a list of points for a chevron shape comprised of two line segments intersecting at a right angle at the midpoint of s1
, which can then be passed to pathFromPoints
to draw the chevron.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | A line |
padding | ℝ | Real Number | Length of each line segment |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
innerPointOffset
Return a point located at padding
of a line s1
offset by padding
in its normal direction (for making right angle markers).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pt1 | ℝ² | 2d Vector of Reals | First point |
pt2 | ℝ² | 2d Vector of Reals | Second point |
pt3 | ℝ² | 2d Vector of Reals | Third point |
padding | ℝ | Real Number | Offset from line to returned point |
Returns: ℝ² (2d Vector of Reals)
ticksOnLine
Create equally spaced tick marks centered at the midpoint of a line
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pt1 | ℝ² | 2d Vector of Reals | starting point of a line |
pt2 | ℝ² | 2d Vector of Reals | ending point of a line |
spacing | ℝ | Real Number | space in px between each tick |
numTicks | ℤ⁺ | Positive Integer | number of tick marks to create |
tickLength | ℝ | Real Number | 1/2 length of each tick |
Returns: PathCmd (Path Command)
orientedSquare
Given two orthogonal segments that intersect at intersection
, and a size len
return a path comprised of three points that describe a perpendicular mark at the angle where the segments intersect.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | LineShape | Line Shape | First line segment |
s2 | LineShape | Line Shape | Second line segment |
intersection | ℝ² | 2d Vector of Reals | Point of intersection |
len | ℝ | Real Number | Side length of square marker |
Returns: PathCmd (Path Command)
triangle
Given three lines l1, l2, l3
that already form a triangle, return a path that describes the triangle (which can then be filled, etc.).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
l1 | LineShape | Line Shape | First line |
l2 | LineShape | Line Shape | Second line |
l3 | LineShape | Line Shape | Third line |
Returns: PathCmd (Path Command)
average2
Return the average of floats x
and y
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
Returns: ℝ (Real Number)
average
Return the average of the floats in the list xs
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
xs | ℝⁿ | Vector of Reals |
|
Returns: ℝ (Real Number)
unit
Return the normalized version of vector v
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals |
|
Returns: ℝⁿ (Vector of Reals)
random
Uniformly sample a random value in the range from minVal
to maxVal
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
minVal | ℝ | Real Number | minimum value |
maxVal | ℝ | Real Number | maximum value |
Returns: ℝ (Real Number)
normalRandom
Sample a normal distribution with mean 0 and standard deviation 1.
Returns: ℝ (Real Number)
triangleRandom
Sample a point from the uniform distribution over a triangle with vertices a
, b
, and c
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a | ℝ² | 2d Vector of Reals | First vertex |
b | ℝ² | 2d Vector of Reals | Second vertex |
c | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝⁿ (Vector of Reals)
sampleColor
Sample a random color once, with opacity alpha
and color type colorType
("rgb"
or "hsv"
).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
alpha | [0,1] | Real Number in Unit Interval | Opacity |
colorType | "rgb" | "hsv" | Color Type | Color model |
Returns: Color (Color)
randomIndex
Uniformly sample a random integer value in the range from minIndex
to maxIndex
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
minIndex | ℝ | Real Number | minimum index |
maxIndex | ℝ | Real Number | maximum index |
Returns: ℤ⁺ (Positive Integer)
setOpacity
Set the opacity of a color color
to frac
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
color | Color | Color | Color |
frac | [0,1] | Real Number in Unit Interval | Opacity |
Returns: Color (Color)
mul
Multiply a matrix m
and a vector v
(where v
is implicitly treated as a column vector).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
m | (ℝⁿ)ᵐ | List of Real Vectors | A matrix |
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝⁿ (Vector of Reals)
barycenter
Return the barycenter of the triangle with vertices a
, b
, c
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
a | ℝ² | 2d Vector of Reals | First vertex |
b | ℝ² | 2d Vector of Reals | Second vertex |
c | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝ² (2d Vector of Reals)
circumcenter
Return the circumcenter of the triangle with vertices p
, q
, r
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝ² | 2d Vector of Reals | First vertex |
q | ℝ² | 2d Vector of Reals | Second vertex |
r | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝ² (2d Vector of Reals)
circumradius
Return the circumradius of the triangle with vertices p
, q
, r
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝ² | 2d Vector of Reals | First vertex |
q | ℝ² | 2d Vector of Reals | Second vertex |
r | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝ (Real Number)
incenter
Return the incenter of the triangle with vertices p
, q
, r
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝ² | 2d Vector of Reals | First vertex |
q | ℝ² | 2d Vector of Reals | Second vertex |
r | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝ² (2d Vector of Reals)
inradius
Return the inradius of the triangle with vertices p
, q
, r
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
p | ℝ² | 2d Vector of Reals | First vertex |
q | ℝ² | 2d Vector of Reals | Second vertex |
r | ℝ² | 2d Vector of Reals | Third vertex |
Returns: ℝ (Real Number)
sqr
Return the square of the number x
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
sqrt
Return the square root of number x
. (Note: if x < 0
you may get NaN
s)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
max
Return the max of the numbers x
, y
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
Returns: ℝ (Real Number)
min
Return the min of the numbers x
, y
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
y | ℝ | Real Number |
|
Returns: ℝ (Real Number)
abs
Return the absolute value of the number x
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
x | ℝ | Real Number |
|
Returns: ℝ (Real Number)
toRadians
Convert the angle theta
from degrees to radians.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number |
|
Returns: ℝ (Real Number)
toDegrees
Convert the angle theta
from radians to degrees.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number |
|
Returns: ℝ (Real Number)
norm
Return the Euclidean norm of the vector v
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
normsq
Return the Euclidean norm squared of the vector v
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
vdist
Return the Euclidean distance between the vectors v
and w
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | A vector |
w | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
vmul
Returns the scalar-vector product.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | ℝ | Real Number | A scalar |
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝⁿ (Vector of Reals)
vdistsq
Return the Euclidean distance squared between the vectors v
and w
.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | A vector |
w | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
angleOf
Return the angle made by the vector v
with the positive x-axis.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝⁿ | Vector of Reals | A vector |
Returns: ℝ (Real Number)
rot90
Rotate a 2D vector v
by 90 degrees counterclockwise.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rotateBy
Rotate a 2D vector v
by theta degrees counterclockwise.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
v | ℝ² | 2d Vector of Reals | A vector |
theta | ℝ | Real Number | degrees to rotate counterclockwise |
Returns: ℝ² (2d Vector of Reals)
signedDistance
Return the signed distance between a shape and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ (Real Number)
signedDistanceRect
Returns the distance between a rect and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | |
pt | ℝ² | 2d Vector of Reals |
Returns: ℝ (Real Number)
signedDistanceCircle
Returns the distance between a circle and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ (Real Number)
signedDistancePolygon
Returns the distance between a polygon and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | points of the polygon |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ (Real Number)
signedDistanceEllipse
Returns the distance between an ellipse and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of ellipse |
rx | ℝ | Real Number | horizontal radius of ellipse |
ry | ℝ | Real Number | vertical radius of ellipse |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ (Real Number)
signedDistanceLine
Returns the distance between a line and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | start of line |
end | ℝ² | 2d Vector of Reals | end of line |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ (Real Number)
signedDistancePolyline
Returns the distance between a line and a polyline
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | points of the polyline |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ (Real Number)
signedDistanceGroup
Returns the signed distance between a group of shapes and a point
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | |
pt | ℝ² | 2d Vector of Reals |
Returns: ℝ (Real Number)
unitVector
Construct a unit vector u in the direction of the given angle theta (in radians).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
theta | ℝ | Real Number | direction |
Returns: ℝ² (2d Vector of Reals)
rayIntersect
Given a point p and vector v, find the first point where the ray r(t)=p+tv intersects the given shape S. If there are no intersections, returns p.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
S | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectDistance
Given a point p and vector v, returns the distance to the first point where the ray r(t)=p+tv intersects the shape S. If there are no intersections, returns Infinity.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
S | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectCircle
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectCircleDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectEllipse
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | |
rx | ℝ | Real Number | |
ry | ℝ | Real Number | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectEllipseDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | |
rx | ℝ | Real Number | |
ry | ℝ | Real Number | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectLine
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | |
end | ℝ² | 2d Vector of Reals | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectLineDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | |
end | ℝ² | 2d Vector of Reals | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectRect
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectRectDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectPoly
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | |
closed | true | false | Boolean Value | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectPolyDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | |
closed | true | false | Boolean Value | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectGroup
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectGroupDistance
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ (Real Number)
rayIntersectNormal
Given a point p and vector v, find the unit normal at the first point where the ray r(t)=p+tv intersects the given shape S. If there are no intersections, returns (0,0).
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
S | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalCircle
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalEllipse
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | |
rx | ℝ | Real Number | |
ry | ℝ | Real Number | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalLine
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | |
end | ℝ² | 2d Vector of Reals | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalRect
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalPoly
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | |
closed | true | false | Boolean Value | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
rayIntersectNormalGroup
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | |
p | ℝ² | 2d Vector of Reals | A point |
v | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
closestPoint
Returns a point on the shape s closest to a query point p. If this point is not unique, an arbitrary choice is made.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A vector |
Returns: ℝ² (2d Vector of Reals)
closestPointCircle
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestPointRect
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestPointLine
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | start point of line |
end | ℝ² | 2d Vector of Reals | end point of line |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestPointEllipse
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of ellipse |
rx | ℝ | Real Number | horizontal radius of ellipse |
ry | ℝ | Real Number | vertical radius of ellipse |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestPointPoly
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | points of the polygon |
closed | true | false | Boolean Value | whether or not the polygon is closed |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestPointGroup
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | shapes of the group |
pt | ℝ² | 2d Vector of Reals | the point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePoint
Returns a point on the visibility silhouette of shape s closest to a query point p. If this point is not unique, an arbitrary choice is made. If no such point exists, the query point p is returned.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointCircle
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of circle |
r | ℝ | Real Number | radius of circle |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointEllipse
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | |
rx | ℝ | Real Number | |
ry | ℝ | Real Number | |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointLine
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start | ℝ² | 2d Vector of Reals | |
end | ℝ² | 2d Vector of Reals | |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointRect
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointPolyline
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝ²)ⁿ | List of 2d Real Vectors | |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointPolygon
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝ²)ⁿ | List of 2d Real Vectors | |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouettePointGroup
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shapes | Shape[] | List of shapes | |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ² (2d Vector of Reals)
closestSilhouetteDistance
Returns the distance to the closest point on the visibility silhouette of shape s relative to query point p. If no such point exists, returns Infinity.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | EquationShape | ImageShape | RectangleShape | TextShape | CircleShape | PolygonShape | LineShape | PolylineShape | EllipseShape | GroupShape | any of: any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape, or Circle Shape, or Polygon Shape, or Line Shape, or Polyline Shape, or Ellipse Shape, or Group Shape | A shape |
p | ℝ² | 2d Vector of Reals | A point |
Returns: ℝ (Real Number)
rectLineDist
Return the distance between a rectangle (defined using the bottom-left and top-right points) and a line (defined using start and end points)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
bottomLeft | ℝ² | 2d Vector of Reals | bottom-left point of rectangle |
topRight | ℝ² | 2d Vector of Reals | top-right point of rectangle |
start | ℝ² | 2d Vector of Reals | start point of line |
end | ℝ² | 2d Vector of Reals | end point of line |
Returns: ℝ (Real Number)
shapeDistance
Return the distance between two shapes.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s1 | Shape | Any Shape | a shape |
s2 | Shape | Any Shape | a shape |
Returns: ℝ (Real Number)
shapeDistanceCircles
Return the distance between two circles.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c1 | ℝ² | 2d Vector of Reals | center of first circle |
r1 | ℝ | Real Number | radius of first circle |
c2 | ℝ² | 2d Vector of Reals | center of second circle |
r2 | ℝ | Real Number | radius of second circle |
Returns: ℝ (Real Number)
shapeDistanceRects
Return the distance between two rectangles.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect1 | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the first rectangle. |
rect2 | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the second rectangle. |
Returns: ℝ (Real Number)
shapeDistanceRectLine
Returns the distance between a rectangle and a line.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle. |
start | ℝ² | 2d Vector of Reals | The start point of the line |
end | ℝ² | 2d Vector of Reals | The end point of the line |
Returns: ℝ (Real Number)
shapeDistanceRectlikePolyline
Returns the distance between a rectangle and a polyline.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle. |
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polyline |
Returns: ℝ (Real Number)
shapeDistancePolys
Returns the distance between two polygons.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts1 | (ℝ²)ⁿ | List of 2d Real Vectors | The list of points for the first polygon |
pts2 | (ℝ²)ⁿ | List of 2d Real Vectors | The list of points for the second polygon |
Returns: ℝ (Real Number)
shapeDistanceRectCircle
Returns the distance between a rectangle and a circle.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
rect | (ℝ²)ⁿ | List of 2d Real Vectors | The top-right, top-left, bottom-left, bottom-right points (in that order) of the rectangle. |
c | ℝ² | 2d Vector of Reals | center of the circle |
r | ℝ | Real Number | radius of the circle |
Returns: ℝ (Real Number)
shapeDistancePolyEllipse
Returns the distance between a polygon and an ellipse.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
pts | (ℝ²)ⁿ | List of 2d Real Vectors | The list of points for the polygon |
c | ℝ² | 2d Vector of Reals | center of the ellipse |
rx | ℝ | Real Number | horizontal radius of ellipse |
ry | ℝ | Real Number | vertical radius of ellipse |
Returns: ℝ (Real Number)
shapeDistanceCircleLine
Returns the distance between a circle and a line.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
c | ℝ² | 2d Vector of Reals | center of the circle |
r | ℝ | Real Number | radius of the circle |
start | ℝ² | 2d Vector of Reals | start point of line |
end | ℝ² | 2d Vector of Reals | end point of line |
Returns: ℝ (Real Number)
shapeDistanceLines
Returns the distance between two lines.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
start1 | ℝ² | 2d Vector of Reals | start point of line |
end1 | ℝ² | 2d Vector of Reals | end point of line |
start2 | ℝ² | 2d Vector of Reals | start point of line |
end2 | ℝ² | 2d Vector of Reals | end point of line |
Returns: ℝ (Real Number)
signedArea
Returns the signed area enclosed by a polygonal chain given its nodes
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
Returns: ℝ (Real Number)
turningNumber
Returns the turning number of polygonal chain given its nodes
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
Returns: ℝ (Real Number)
perimeter
Returns the total length of polygonal chain given its nodes
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of polygonal chain |
closed | true | false | Boolean Value | whether the polygonic chain is closed |
Returns: ℝ (Real Number)
isoperimetricRatio
Returns the isoperimetric ratio (perimeter squared divided by enclosed area)
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether the curve is closed |
Returns: ℝ (Real Number)
elasticEnergy
Returns integral of curvature squared along the curve
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: ℝ (Real Number)
totalCurvature
Returns integral of curvature along the curve
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
signed | true | false | Boolean Value | whether curvature is signed |
Returns: ℝ (Real Number)
lengthK
Returns the sum of all line segment lengths raised to k
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
k | ℝ | Real Number | exponent for line segments |
Returns: ℝ (Real Number)
maxCurvature
Returns the maximum value of curvature along the curve
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: ℝ (Real Number)
pElasticEnergy
Returns integral of curvature raised to p
along the curve
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
p | ℝ | Real Number | exponent for curvature |
Returns: ℝ (Real Number)
inflectionEnergy
Returns integral of curvature derivative raised to p
along the curve
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
p | ℝ | Real Number | exponent for curvature derivative |
Returns: ℝ (Real Number)
tangentVectors
Returns list of n
tangent vectors given a list of n
points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
normalVectors
Returns list of n
normal vectors given a list of n
points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
binormalVectors
Returns list of n
binormal vectors given a list of n
points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
evoluteCurve
Returns evolute curve from a list of n
points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
offsetCurve
Returns an offset version of the input curve.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
magnitude | ℝ | Real Number | magnitude of the offset |
Returns: (ℝⁿ)ᵐ (List of Real Vectors)
curvatures
Returns list of n
curvature values given a list of n
points.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | points of curve |
closed | true | false | Boolean Value | whether curve is closed |
Returns: ℝⁿ (Vector of Reals)
centerOfMass
Returns center of mass for a 2D point cloud
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝ²)ⁿ | List of 2d Real Vectors | points of curve |
Returns: ℝ² (2d Vector of Reals)
clip
Describes clipping to a shape
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
shape | Shape | Any Shape |
Returns: ClipData (Shape clip data)
bboxPts
Returns the top-left, top-right, bottom-right, bottom-left points (in that order) of the axis-aligned bounding box of a shape
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | Shape | Any Shape | a shape |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
tsneEnergy
Returns T-SNE energy
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
points | (ℝⁿ)ᵐ | List of Real Vectors | high dimensional points |
projectedPoints | (ℝⁿ)ᵐ | List of Real Vectors | projected, low dimensional points |
Returns: ℝ (Real Number)
rectPts
Returns the top-left, top-right, bottom-right, bottom-left points of a rect-like shape. This takes into account rotation.
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
s | EquationShape | ImageShape | RectangleShape | TextShape | any of: Equation Shape, or Image Shape, or Rectangle Shape, or Text Shape |
Returns: (ℝ²)ⁿ (List of 2d Real Vectors)
TeXify
Returns the TeX-fied version of a string where subscripts are handled in a way suitable for equation rendering. For example, "hello_world" becomes "{hello}_{world}".
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
str | String | String |
Returns: String (String)
repeat
Returns a vector of n elements of K
Parameters:
Name | Type | Type Description | Description |
---|---|---|---|
n | ℕ | Natural Number | |
k | ℝ | Real Number |