Class QuaternionExtensions
Extension methods for advanced Quaternion operations. Provides interpolation methods with control over rotation direction.
Namespace: NWH.Common.Utility
Assembly: NWH.Common.dll
Syntax
public static class QuaternionExtensions
Methods
| Edit this page View SourceAdd(Quaternion, Quaternion)
Adds two quaternions component-wise.
Declaration
public static Quaternion Add(Quaternion p, Quaternion q)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | p | First quaternion. |
| Quaternion | q | Second quaternion. |
Returns
| Type | Description |
|---|---|
| Quaternion | Component-wise sum. |
Lerp(Quaternion, Quaternion, float, bool)
Linear interpolation between two quaternions with optional short/long path control. Unlike Unity's Quaternion.Lerp, this allows choosing rotation direction.
Declaration
public static Quaternion Lerp(Quaternion p, Quaternion q, float t, bool shortWay)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | p | Starting rotation. |
| Quaternion | q | Target rotation. |
| float | t | Interpolation factor (0 to 1). |
| bool | shortWay | True for shortest rotation path, false for longest. |
Returns
| Type | Description |
|---|---|
| Quaternion | Interpolated quaternion. |
ScalarMultiply(Quaternion, float)
Multiplies all components of a quaternion by a scalar value.
Declaration
public static Quaternion ScalarMultiply(Quaternion input, float scalar)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | input | Input quaternion. |
| float | scalar | Scalar multiplier. |
Returns
| Type | Description |
|---|---|
| Quaternion | Scaled quaternion. |
Slerp(Quaternion, Quaternion, float, bool)
Spherical linear interpolation between two quaternions with optional short/long path control. Provides smooth rotation interpolation with control over rotation direction.
Declaration
public static Quaternion Slerp(Quaternion p, Quaternion q, float t, bool shortWay)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | p | Starting rotation. |
| Quaternion | q | Target rotation. |
| float | t | Interpolation factor (0 to 1). |
| bool | shortWay | True for shortest rotation path, false for longest. |
Returns
| Type | Description |
|---|---|
| Quaternion | Interpolated quaternion. |