-
Notifications
You must be signed in to change notification settings - Fork 0
Quaternion Extensions
Andrzej Kebab edited this page Feb 2, 2024
·
1 revision
Deconstructs a Quaternion instance into its individual components.
Quaternion quaternion = // initialize your Quaternion
float x, y, z, w;
quaternion.Deconstruct(out x, out y, out z, out w);Parameters:
-
quaternion: The Quaternion instance.
Outputs:
-
x: The x component of the Quaternion. -
y: The y component of the Quaternion. -
z: The z component of the Quaternion. -
w: The w component of the Quaternion.
Creates a new Quaternion instance with the specified components, or the original components if not specified.
Quaternion originalQuaternion = // initialize your Quaternion
float? x = // optional
float? y = // optional
float? z = // optional
float? w = // optional
Quaternion newQuaternion = originalQuaternion.With(x, y, z, w);Parameters:
-
originalQuaternion: The original Quaternion instance. -
x: The x component of the new Quaternion. If null, the x component of the original Quaternion is used. -
y: The y component of the new Quaternion. If null, the y component of the original Quaternion is used. -
z: The z component of the new Quaternion. If null, the z component of the original Quaternion is used. -
w: The w component of the new Quaternion. If null, the w component of the original Quaternion is used.
Returns:
-
newQuaternion: A new Quaternion instance with the specified components.
Creates a new Quaternion instance with the specified Euler angles, or the original Euler angles if not specified.
Quaternion originalQuaternion = // initialize your Quaternion
float? x = // optional
float? y = // optional
float? z = // optional
Quaternion newQuaternion = originalQuaternion.WithEuler(x, y, z);Parameters:
-
originalQuaternion: The original Quaternion instance. -
x: The x component of the new Quaternion's Euler angles. If null, the x component of the original Quaternion's Euler angles is used. -
y: The y component of the new Quaternion's Euler angles. If null, the y component of the original Quaternion's Euler angles is used. -
z: The z component of the new Quaternion's Euler angles. If null, the z component of the original Quaternion's Euler angles is used.
Returns:
-
newQuaternion: A new Quaternion instance with the specified Euler angles.
Creates a new Quaternion instance with the specified angle and axis, or the original angle and axis if not specified.
Quaternion originalQuaternion = // initialize your Quaternion
float? angle = // optional
Vector3? axis = // optional
Quaternion newQuaternion = originalQuaternion.WithAngleAxis(angle, axis);Parameters:
-
originalQuaternion: The original Quaternion instance. -
angle: The angle of the new Quaternion. If null, the angle of the original Quaternion is used. -
axis: The axis of the new Quaternion. If null, the axis of the original Quaternion is used.
Returns:
-
newQuaternion: A new Quaternion instance with the specified angle and axis.
Raises a Quaternion to a specified power.
Quaternion quaternion = // initialize your Quaternion
float power = // specify the power
Quaternion result = quaternion.Pow(power);Parameters:
-
quaternion: The Quaternion instance. -
power: The power to raise the Quaternion to.
Returns:
-
result: The Quaternion raised to the specified power.
Calculates the exponential of a Quaternion.
Quaternion quaternion = // initialize your Quaternion
Quaternion result = quaternion.Exp();Parameters:
-
quaternion: The Quaternion instance.
Returns:
-
result: The exponential of the Quaternion.
Calculates the magnitude of a Quaternion.
Quaternion quaternion = // initialize your Quaternion
float magnitude = quaternion.Magnitude();Parameters:
-
quaternion: The Quaternion instance.
Returns:
-
magnitude: The magnitude of the Quaternion.
Multiplies a Quaternion by a scalar.
Quaternion quaternion = // initialize your Quaternion
float scalar = // specify the scalar
Quaternion result = quaternion.ScalarMultiply(scalar);Parameters:
-
quaternion: The Quaternion instance. -
scalar: The scalar to multiply the Quaternion by.
Returns:
-
result: The Quaternion multiplied by the scalar.