Skip to main content

Module plain

Module plain 

Source
Expand description

Vectors in plain numbers, [f64; N]: for what is only ever a free choice or a picture — a section placed along a spline, a sample to draw, a point to suggest — never for a result the kernel reasons about, which is a crate::vector::Vector of scalars.

Where a direction has no length, normalize gives none; what to do then is the caller’s choice, made where it is called.

Functions§

add
bounds
The box around points: its lowest corner and its highest, or None if there are no points.
centroid
The mean of points, summed in their order and then divided by their count, or None if there are no points.
cross
The cross product a x b.
cross2
The 2-D cross product a.x b.y - a.y b.x: positive where b lies counter-clockwise of a.
diagonal
The length of the diagonal of the box from lo to hi: how far apart any two points in it can be.
distance
How far a is from b.
dot
inverse2
The inverse of the 2x2 matrix m: not finite where it is singular.
norm
The length of a, sqrt(a . a).
normalize
a scaled to unit length, or None if it has no finite, non-zero one.
scale
signed_area2
Twice the signed area of the closed polygon poly (shoelace formula): positive where it runs counter-clockwise.
solve2
The solution x of m x = r for the 2x2 matrix m, by Cramer’s rule: not finite where m is singular.
sub
unwrap_angle
The angle a, turned by whole turns to within half a turn of reference: in [reference - π, reference + π), how an angle measured in (-π, π] is followed on from the one before.

Type Aliases§

P2
[x, y].
P3
[x, y, z].