Reese's DOTS Math Extensions

November 11, 2025 · View on GitHub

This project is archived—no longer maintained. So long, and thanks for all the fish!

Includes math functions missing from DOTS.

Import

This requires Unity editor 2019.3 or greater. Copy one of the below Git URLs:

  • HTTPS: https://github.com/reeseschultz/ReeseUnityDemos.git#math
  • SSH: git@github.com:reeseschultz/ReeseUnityDemos.git#math

Then go to Window ⇒ Package Manager in the editor. Press the + symbol in the top-left corner, and then click on Add package from git URL. Paste the text you copied and finally click Add.

Usage

Be sure to import Reese.Math in any file where you intend to use these extensions!

Extensions

float4x4 Extensions

MethodReturn TypeDescription
MultiplyPoint3x4(float3 point)float3Changes the basis of a point with the given transform.

float3 Extensions

MethodReturn TypeDescription
ref MoveTowards(float3 to, float maxDelta)float3Moves from a point to another point by the max delta (moves less than the max delta if target is closer than the max delta).
MultiplyPoint3x4(float4x4 transform)float3Changes the basis of a point with the given transform.
ToLocal(LocalToWorld localToWorld)float3Transforms a point from world to local space.
ToWorld(LocalToWorld localToWorld)float3Transforms a point from local to world space.
ProjectOnPlane(float3 normal)float3Projects a float3 vector onto a planar normal.
AxialReplacement(float3 replacingVector, float3 axis)float3Component-wise replacement along the provided axes.
InvertToUnsignedAxis()float3Inverts to an unsigned axis. For example, (-1, 0, 1) becomes (0, 1, 0).
AngleRadians(float3 to)floatReturns the angle between two float3s in radians.
AngleDegrees(float3 to)floatReturns the angle between two float3s in degrees.
SignedAngleRadians(float3 to, float3 axis)floatReturns the signed angle between two float3s in radians about the given axis.
SignedAngleDegrees(float3 to, float3 axis)floatReturns the signed angle between two float3s in degrees about the given axis.
Angle360(float3 to, float3 right)floatReturns the angle between two float3s ranging between 0 and 360 degrees.
FromToRotation(float3 to)quaternionRotates from one rotation to another.
GetWorldRotationToTarget(LocalToWorld localToWorld, float3 planarAxis = default)quaternionGets the rotation to the target in world space.

quaternion Extensions

MethodReturn TypeDescription
ToLocal(LocalToWorld localToWorld)quaternionTransforms a quaternion from world to local space.
ToWorld(LocalToWorld localToWorld)quaternionTransforms a quaternion from local to world space.
RotateTowardsRadians(quaternion to, float deltaRadians)quaternionReturns a quaternion interpolated by delta radians.
RotateTowardsDegrees(quaternion to, float deltaDegrees)quaternionReturns a quaternion interpolated by delta degrees.
AngleRadians(quaternion to)floatReturns the angle between two quaternions in radians.
AngleDegrees(quaternion to)floatReturns the angle between two quaternions in degrees.

Contributing

All contributions to this repository are licensed under MIT.