Vectors¶
VectorXY represents a two-dimensional vector with single-precision floating-point components. VectorXYInt represents the same concept with integer components.
Basic Operations¶
using Akeldov.Math.Spatial2D;
var a = new VectorXY(3f, 4f);
var b = new VectorXY(1f, 2f);
VectorXY sum = a + b;
VectorXY difference = a - b;
VectorXY scaled = a * 2f;
float length = a.Length;
float squaredLength = a.SquaredLength;
VectorXY direction = a.Normalize();
Dot, Cross, and Angle¶
var right = new VectorXY(1f, 0f);
var up = new VectorXY(0f, 1f);
float dot = VectorXY.Dot(right, up);
float cross = VectorXY.Cross(right, up);
float angleRad = VectorXY.Angle(right, up);
VectorXY.Angle(from, to) returns a signed angle in radians.
Extension Methods¶
The vector extensions cover common geometry tasks:
Distancefor Euclidean distance.Rotatefor rotation around zero or a pivot.Transformfor scale, rotation, and offset.Clamp,ClampMin, andClampMax.HadamardMultiplyandHadamardDivide.Roundfor component rounding.SumandAveragefor vector sequences.