Mathf

General purpose Vector and Quaternion operations that are not present in Numerics by default.

Fields

RadiansToDegrees (float) = 180f / MathF.PI: Converts radians to degrees.

DegreesToRadians (float) = MathF.PI / 180: Converts degrees to radians.

Properties

Up

(Vector3): Gets the up vector (0, 1, 0).

Down

(Vector3): Gets the down vector (0, -1, 0).

(Vector3): Gets the right vector (1, 0, 0).

Left

(Vector3): Gets the left vector (-1, 0, 0).

Forward

(Vector3): Gets the forward vector (0, 0, 1).

Backward

(Vector3): Gets the backward vector (0, 0, -1).

Public Methods

ToQuaternion

public static Quaternion ToQuaternion(Vector3 vector3)

Converts a vector in degrees to a quaternion.

Parameters:

  • vector3 (Vector3): The vector in degrees to convert.

Returns: Quaternion

  • A quaternion representing the input vector.

UnwindDegrees

public static float UnwindDegrees(float angle)

Unwinds an angle in degrees to the range [-180, 180].

Parameters:

  • angle (float): The angle to unwind.

Returns: float

  • The unwound angle in degrees.

ToEulerDegrees

public static Vector3 ToEulerDegrees(Quaternion quat)

Converts a quaternion to Euler angles in degrees.

Parameters:

  • quat (Quaternion): The quaternion to convert.

Returns: Vector3

  • Euler angles in degrees (X: Pitch, Y: Yaw, Z: Roll).

Rotate

public static Vector3 Rotate(Quaternion me, Vector3 v)

Rotates a vector by a quaternion.

Parameters:

  • me (Quaternion): The quaternion representing the rotation.
  • v (Vector3): The vector to rotate.

Returns: Vector3

  • The rotated vector.