# Quaternion

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/numerics/struct-quaternion/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct Quaternion
```

A vector that is used to encode three-dimensional physical rotations.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L15)

## Members

- [`x`](#struct_field-x)
- [`y`](#struct_field-y)
- [`z`](#struct_field-z)
- [`w`](#struct_field-w)
- [`IDENTITY`](#assoc_const-identity)
- [`ZERO`](#assoc_const-zero)
- [`new`](#function-new)
- [`from_vector3`](#function-from_vector3)
- [`is_identity`](#function-is_identity)
- [`concatenate`](#function-concatenate)
- [`conjugate`](#function-conjugate)
- [`create_from_axis_angle`](#function-create_from_axis_angle)
- [`create_from_rotation_matrix`](#function-create_from_rotation_matrix)
- [`create_from_yaw_pitch_roll`](#function-create_from_yaw_pitch_roll)
- [`dot`](#function-dot)
- [`inverse`](#function-inverse)
- [`length`](#function-length)
- [`length_squared`](#function-length_squared)
- [`lerp`](#function-lerp)
- [`normalize`](#function-normalize)
- [`slerp`](#function-slerp)

<a id="struct_field-x"></a>

### x

```rust
x: f32
```

The X value of the vector component of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L17)

<a id="struct_field-y"></a>

### y

```rust
y: f32
```

The Y value of the vector component of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L19)

<a id="struct_field-z"></a>

### z

```rust
z: f32
```

The Z value of the vector component of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L21)

<a id="struct_field-w"></a>

### w

```rust
w: f32
```

The rotation component of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L23)

<a id="assoc_const-identity"></a>

### IDENTITY

```rust
const IDENTITY: Quaternion
```

A quaternion that represents no rotation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L28)

<a id="assoc_const-zero"></a>

### ZERO

```rust
const ZERO: Quaternion
```

A quaternion whose components are all zero.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L31)

<a id="function-new"></a>

### new

```rust
const fn new(x: f32, y: f32, z: f32, w: f32) -> Self
```

Constructs a quaternion from the specified components.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L35)

<a id="function-from_vector3"></a>

### from_vector3

```rust
const fn from_vector3(vector_part: Vector3, scalar_part: f32) -> Self
```

Creates a quaternion from the specified vector and rotation parts.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L41)

<a id="function-is_identity"></a>

### is_identity

```rust
fn is_identity(self: &Self) -> bool
```

Gets a value that indicates whether the current instance is the identity quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L47)

<a id="function-concatenate"></a>

### concatenate

```rust
fn concatenate(value1: Quaternion, value2: Quaternion) -> Quaternion
```

Concatenates two quaternions: the result represents the `value1`
rotation followed by the `value2` rotation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L53)

<a id="function-conjugate"></a>

### conjugate

```rust
fn conjugate(value: Quaternion) -> Quaternion
```

Returns the conjugate of a specified quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L61)

<a id="function-create_from_axis_angle"></a>

### create_from_axis_angle

```rust
fn create_from_axis_angle(axis: Vector3, angle: f32) -> Quaternion
```

Creates a quaternion from a unit vector and an angle to rotate around the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L66)

<a id="function-create_from_rotation_matrix"></a>

### create_from_rotation_matrix

```rust
fn create_from_rotation_matrix(matrix: Matrix4x4) -> Quaternion
```

Creates a quaternion from the specified rotation matrix.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L75)

<a id="function-create_from_yaw_pitch_roll"></a>

### create_from_yaw_pitch_roll

```rust
fn create_from_yaw_pitch_roll(yaw: f32, pitch: f32, roll: f32) -> Quaternion
```

Creates a new quaternion from the given yaw, pitch, and roll.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L114)

<a id="function-dot"></a>

### dot

```rust
fn dot(quaternion1: Quaternion, quaternion2: Quaternion) -> f32
```

Calculates the dot product of two quaternions.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L139)

<a id="function-inverse"></a>

### inverse

```rust
fn inverse(value: Quaternion) -> Quaternion
```

Returns the inverse of a quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L147)

<a id="function-length"></a>

### length

```rust
fn length(self: &Self) -> f32
```

Calculates the length of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L162)

<a id="function-length_squared"></a>

### length_squared

```rust
fn length_squared(self: &Self) -> f32
```

Calculates the squared length of the quaternion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L168)

<a id="function-lerp"></a>

### lerp

```rust
fn lerp(quaternion1: Quaternion, quaternion2: Quaternion, amount: f32) -> Quaternion
```

Performs a linear interpolation between two quaternions based on a
value that specifies the weighting of the second quaternion. The
result is normalized.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L175)

<a id="function-normalize"></a>

### normalize

```rust
fn normalize(value: Quaternion) -> Quaternion
```

Divides each component of a specified quaternion by its length.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L201)

<a id="function-slerp"></a>

### slerp

```rust
fn slerp(quaternion1: Quaternion, quaternion2: Quaternion, amount: f32) -> Quaternion
```

Interpolates between two quaternions, using spherical linear interpolation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/numerics/quaternion.rs#L212)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `Add`
- `Sub`
- `Neg`
- `Mul`
- `Mul<f32>`
- `Div`
- `Display`
- `IInterpolator<Quaternion>`
- `From<Quaternion>`
- `ExpressionVariantValue`
- `ServerPropertyValue`
- `BatchValue`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
