package
0.0.0-20241019203012-a2ad2ed164c2
Repository: https://github.com/soypat/glgl.git
Documentation: pkg.go.dev
# Functions
AbsElem returns the vector with components set to their absolute value.
Add returns the vector sum of p and q.
AddMat2 adds two 2x2 matrices together.
AddScalar adds f to all of v's components and returns the result.
AppendGrid splits the argument bounds [Box] x,y axes by nx,ny, respectively and generates points on the vertices generated by the division and appends them to dst, returning the result.
CeilElem returns a with Ceil applied to each component.
Clamp returns v with its elements clamped to Min and Max's components.
Cos returns the cosine of the opening angle between p and q.
CosElem returns cos(a) component-wise.
Cross returns the cross product p×q.
DivElem returns the Hadamard product between vector a and the inverse components of vector b.
Dot returns the dot product p·q.
EqualElem checks equality between vector elements to within a tolerance.
EqualMat2 tests the equality of 2x2 matrices.
FloorElem returns a with Floor applied to each component.
IdentityMat2 returns the 2x2 identity matrix.
InterpElem performs a linear interpolation between x and y's elements, mapping with a's values in interval [0,1].
MaxElem return a vector with the maximum components of two vectors.
MinElem return a vector with the minimum components of two vectors.
MulElem returns the Hadamard product between vectors a and b.
MulMat2 multiplies two 2x2 matrices.
MulMatVec performs matrix multiplication on v:
result = M * v.
MulMatVecTrans Performs transposed matrix multiplication on v:
result = Mᵀ * v.
NewBox is shorthand for Box{Min:Vec{x0,y0}, Max:Vec{x1,y1}}.
NewCenteredBox returns a box centered around center with size dimensions.
NewMat2 instantiates a new matrix from the first 4 floats, row major order.
Norm returns the Euclidean norm of p
|p| = sqrt(p_x^2 + p_y^2).
Norm2 returns the Euclidean squared norm of p
|p|^2 = p_x^2 + p_y^2.
Prod performs vector multiplication as if they were matrices
m = v1 * v2ᵀ.
Rotate returns an orthographic 2x2 rotation matrix (right hand rule).
Round rounds the individual elements of a vector.
Scale returns the vector p scaled by f.
ScaleMat2 multiplies each 2x2 matrix component by a scalar.
Sign returns sign function applied to each individual component of a.
SincosElem returns (sin(a), cos(a)).
SinElem returns sin(a) component-wise.
SmoothStepElem performs element-wise smooth cubic hermite interpolation between 0 and 1 when e0 < x < e1.
Sub returns the vector sum of p and -q.
Unit returns the unit vector colinear to p.
# Structs
Box is a 2D bounding box.
Mat2 is a 2x2 matrix.
PolygonBuilder facilitates polygon construction with arcs, smoothing and chamfers with the [PolygonControlPoint] type.
PolygonControlPoint represents a polygon point joined by two edges, or alternatively a smoothed control point, in which case the vertex does not lie in the polygon.
Vec is a 2D vector.