Anglesclass

Euler angles. Unlike a Rotation, Euler angles can represent multiple revolutions (rotations) around an axis, but suffer from issues like gimbal lock and lack of a defined "up" vector. Use Rotation for most cases.

objectAngles
Namespace
global
Assembly
Sandbox.System
Declaration
public sealed struct Angles

Constructors4

Showing 4 constructors

Methods17

Showing 17 methods

public static Vector3 AngleVector(Angles ang)PUBLICSTATIC

Converts an angle to a forward vector.

ParameterTypeDescription
angAngles
Returns:Vector3

public Vector3 AsVector3()PUBLIC

Return as a Vector3, where x = pitch etc

Returns:Vector3

public static float ClampAngle(float v)PUBLICSTATIC

Clamps the angle to range of [0, 360)

ParameterTypeDescription
vfloat
Returns:float

public Angles Clamped()PUBLIC

Returns clamped version of this object, meaning the angle on each axis is transformed to range of [0,360).

Returns:Angles

public bool IsNearlyZero(double tolerance = 1E-06)PUBLIC

Returns true if this angles object's components are all nearly zero with given tolerance.

ParameterTypeDescription
tolerance = 1E-06double
Returns:bool

public static Angles Lerp(Angles source, Angles target, float frac)PUBLICSTATIC

Performs linear interpolation on the two given angle objects.

ParameterTypeDescription
sourceAnglesAngle A
targetAnglesAngle B
fracfloatFraction in range [0,1] between the 2 angle objects to use for interpolation.
Returns:Angles

public Angles LerpTo(Angles target, float frac)PUBLIC

Performs linear interpolation on the two given angle objects.

ParameterTypeDescription
targetAnglesAngle B
fracfloatFraction in range [0,1] between the 2 angle objects to use for interpolation.
Returns:Angles

public static float NormalizeAngle(float v)PUBLICSTATIC

Normalizes the angle to range of (-180, 180]

ParameterTypeDescription
vfloat
Returns:float

public Angles SnapToGrid(float gridSize, bool sx = True, bool sy = True, bool sz = True)PUBLIC

Snap to grid

ParameterTypeDescription
gridSizefloat
sx = Truebool
sy = Truebool
sz = Truebool
Returns:Angles

public Rotation ToRotation()PUBLIC

Converts these Euler angles to a rotation. The angles will be normalized.

Returns:Rotation

public Angles WithPitch(float pitch)PUBLIC

Returns this angles object with given pitch component.

ParameterTypeDescription
pitchfloat
Returns:Angles

public Angles WithRoll(float roll)PUBLIC

Returns this angles object with given roll component.

ParameterTypeDescription
rollfloat
Returns:Angles

public Angles WithYaw(float yaw)PUBLIC

Returns this angles object with given yaw component.

ParameterTypeDescription
yawfloat
Returns:Angles

Properties3

Showing 3 properties

public Vector3 Angles.Forward { get; set; }PUBLICGETSET

The forward direction vector for this angle.

Returns:Vector3

public Angles Angles.Normal { get; set; }PUBLICGETSET

Returns normalized version of this object, meaning the angle on each axis is normalized to range of (-180,180].

Returns:Angles

public static Angles Angles.Random { get; set; }PUBLICSTATICGETSET

Returns the angles of a uniformly random rotation.

Returns:Angles

On this page