Quarterion

Quaternion Struct

Represents a quaternion orientation.

Syntax

public struct Quaternion

Member Details

Quaternion Constructor

Creates a new quaternion with the supplied values.

Syntax

public Quaternion ([System.Runtime.CompilerServices.IsReadOnly] ref Mono.Simd.Vector4f v)

Parameters

v

Initializes the quaternion from a Mono.Simd.Vector4f.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Quaternion Constructor

Creates a new quaternion with the supplied values.

Syntax

Parameters

x

The x coordinate.

y

The y coordinate.

z

The z coordinate.

w

The w coordinate.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Dot Method

Performs a scalar or dot product.

Syntax

public float Dot ([System.Runtime.CompilerServices.IsReadOnly] ref Quaternion b)

Parameters

b

The second quaternion.

Returns

Returns X*b.X+Y*b.Y+Z*b.Z+W*b.W

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


FromAngleAxis Method

Generates the corresponding quaternion.

Syntax

public static Quaternion FromAngleAxis (float angle, [System.Runtime.CompilerServices.IsReadOnly] ref Vector axis)

Parameters

angle

Angle of rotation in radians

axis

A normalized axis of rotation

Returns

The corresponding quaternion.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


FromEulerAngles Method

Generates the corresponding quaternion.

Syntax

public static Quaternion FromEulerAngles ([System.Runtime.CompilerServices.IsReadOnly] ref Vector a)

Parameters

a

A vector of angles in radians.

Returns

The corresponding quaternion.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


FromLook Method

Creates a new rotation with the specified direction and up vectors.

Syntax

Parameters

facing

The direction to look.

up

The up direction.

Returns

A new quaternion representing this rotation.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


FromLookOrthoNormal Method

Creates a new rotation with the specified direction and up vectors.

Syntax

public static Quaternion FromLookOrthoNormal ([System.Runtime.CompilerServices.IsReadOnly] ref Vector facing, [System.Runtime.CompilerServices.IsReadOnly] ref Vector up, [System.Runtime.CompilerServices.IsReadOnly] ref Vector left)

Parameters

facing

The direction to look.

up

The up direction.

left

The left direction.

Returns

A new quaternion representing this rotation.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


GetEulerAngles Method

Converts this rotation to a vector of euler angles

Syntax

public Vector GetEulerAngles ()

Returns

A vector of angles in radians corresponding to this quaternion.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Identity Field

The identity quaternion.

Syntax

public static readonly Quaternion Identity

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Inverse Method

Gets the Inverse of the quaternion.

Syntax

Returns

A quaternion inverse, such that q * q.Inverse() == q.Inverse() * q == Quaternion.Identity

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Item Property

Allows getting coordinates by index.

Syntax

This is the default property for this class.

public float this [int index] { get; set; }

Parameters

index

0=>X, 1=>Y, 2=>Z, 3=>W

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Length Method

Calculates the length of this quaternion.

Syntax

public float Length ()

Returns

The length of the quaternion.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


LengthSquared Method

Calculates the length squared of this quaternion.

Syntax

public float LengthSquared ()

Returns

The magnitude of the vector.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Normalized Method

Returns a quaternion with the same orientation and unit length.

Syntax

Returns

A quaternion with the same orientation and unit length.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Conversion Method

Converts a Mono.Simd.Vector4f to a quaternion.

Syntax

Parameters

v

The vector to convert

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Conversion Method

Converts a quaternion to a Mono.Simd.Vector4f.

Syntax

Parameters

v

The quaternion to convert

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_Multiply Method

Multiplies two quaternions.

Syntax

public static Quaternion operator* ([System.Runtime.CompilerServices.IsReadOnly] ref Quaternion a, [System.Runtime.CompilerServices.IsReadOnly] ref Quaternion b)

Parameters

a

The first quaternion

b

The second quaternion

Returns

Returns the composed orientation for the two quaternions.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


op_UnaryNegation Method

Negates a quaternion

Syntax

Parameters

q

The quaternion to negate

Returns

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Parse Method

Parse a Quaternion from a string.

Syntax

Parameters

quaternionString

A string of the format "[X,Y,Z,W]"

Returns

The Quaternion parsed from quaternionString.

Exceptions

Type
Reason

If quaternionString is null.

If the string is not a valid quaternion or its components are not valid floats.

Remarks

Example

C# Example

Quaternion myQuat = Quaternion.Parse("[0.0,0.0,0.0,1.0]");

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ShortestRotation Method

Generates the shortest rotation quaternion to rotate from one vector to another.

Syntax

public static Quaternion ShortestRotation ([System.Runtime.CompilerServices.IsReadOnly] ref Vector from, [System.Runtime.CompilerServices.IsReadOnly] ref Vector to)

Parameters

from

Vector rotating from.

to

Vector rotating to.

Returns

The corresponding quaternion.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToAngleAxis Method

Gets the angle-axis representation

Syntax

Parameters

angle

Angle of rotation in radians

axis

A normalized axis of rotation

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToString Method

Generates a string representation of the quaternion.

Syntax

public override string ToString ()

Returns

The quaternion as a string.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ToString Method

Generates a string representation of the quaternion.

Syntax

Parameters

format

Format to use for each of the coordinates.

Returns

The quaternion as a string.

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


TryParse Method

Try to parse a Quaternion from a string.

Syntax

Parameters

quaternionString

A string of the format "[X,Y,Z,W]"

quaternion

The quaternion that will be set if quaternionString represents a valid quaternion.

Returns

True if successfully parsed a quaternion, false if not.

Remarks

Example

C# Example

Quaternion myQuat;
        if (Quaternion.TryParse("[0.0,0.0,0.0,1.0]", out myQuat)
        {
            // myQuat is set.
        }

|

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


W Property

The W coordinate of the quaternion.

Syntax

public float W { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


X Property

The X coordinate of the quaternion.

Syntax

public float X { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Y Property

The Y coordinate of the quaternion.

Syntax

public float Y { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Z Property

The Z coordinate of the quaternion.

Syntax

public float Z { get; set; }

Value

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0



Last updated