Skip to content

Math utilities

Open Javadoc

Vector

Pine uses the following classes to represent 2-, 3- and 4-dimensional vectors with integer or floating point precision.

Vectors with integer precision are often referred to as coordinates and vectors with floating point precision as positions.

Direction

The Direction enum contains 2-dimensional directions (up, down, left and right). The enum provides utilities for mirroring and rotating directions and for converting directions to vectors or to degrees. The x and y properties respectively represent the sine and cosine of the angle of the direction.

Edge alignment

The EdgeAlignment enum contains 1-dimensional points that can be used to represent an anchor point on a line. In user interfaces, this is used to align children to a given side of the cross axis of a CanvasGroup.

float lineLength = 10f;
float lineStart = EdgeAlignment.START.getValue(lineLength); // 0f
float lineMiddle = EdgeAlignment.CENTER.getValue(lineLength); // 5f
float lineEnd = EdgeAlignment.END.getValue(lineLength); // 10f

Grid alignment

The GridAlignment enum contains 2-dimensional anchor points relative to the bottom left corner of a rectangle.