# Vector3D

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-media3d/struct-vector3d/

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

```rust
struct Vector3D
```

A displacement in 3D space, with double-precision components (WPF's
`System.Windows.Media.Media3D.Vector3D`).

This is the vector of the 3D scene model. The base library's `ferroui_base::Vector3D` is the
vector of the reference's composition API; the two convert into each other with `From`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L18)

## Members

- [`x`](#struct_field-x)
- [`y`](#struct_field-y)
- [`z`](#struct_field-z)
- [`new`](#function-new)
- [`length`](#function-length)
- [`length_squared`](#function-length_squared)
- [`normalize`](#function-normalize)
- [`negate`](#function-negate)
- [`dot_product`](#function-dot_product)
- [`cross_product`](#function-cross_product)
- [`angle_between`](#function-angle_between)
- [`parse`](#function-parse)

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

### x

```rust
x: f64
```

The X component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L20)

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

### y

```rust
y: f64
```

The Y component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L22)

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

### z

```rust
z: f64
```

The Z component.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L24)

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

### new

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

A vector with the given components.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L30)

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

### length

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

The length of the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L36)

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

### length_squared

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

The square of the length of the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L42)

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

### normalize

```rust
fn normalize(self: &mut Self)
```

Makes the vector a unit vector of the same direction. The components are first divided by
the largest of their magnitudes, so the length does not overflow. The zero vector becomes
`NaN` components, as in WPF.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L49)

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

### negate

```rust
fn negate(self: &mut Self)
```

Reverses the direction of the vector.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L60)

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

### dot_product

```rust
fn dot_product(vector1: Vector3D, vector2: Vector3D) -> f64
```

The dot product of two vectors.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L66)

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

### cross_product

```rust
fn cross_product(vector1: Vector3D, vector2: Vector3D) -> Vector3D
```

The cross product of two vectors: perpendicular to both, in the right-handed sense.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L72)

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

### angle_between

```rust
fn angle_between(vector1: Vector3D, vector2: Vector3D) -> f64
```

The angle between two vectors, in degrees, from 0 to 180. The angle is computed from the
length of the difference of the unit vectors, which is precise also near 0 and 180 degrees
where the arc cosine of the dot product is not.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L83)

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

### parse

```rust
fn parse(text: &str) -> Result<Self, FormatError>
```

Parses the text form `"x,y,z"` (commas, white space or both between the numbers) in the
invariant culture.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Media3D/vector_3d.rs#L99)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- [`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/)
- `ErasedDestructor`
- `IntoEither`
- `FromIterator<Vector3D>`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- `Add<Vector3D>`
- `Sub<Vector3D>`
- `AddAssign<Vector3D>`
- `SubAssign<Vector3D>`
- `From<Point3D>`
- `From<Size3D>`
- `Clone`
- `Copy`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Default`
- `Add`
- `Add<Point3D>`
- `Sub`
- `Sub<Point3D>`
- `Neg`
- `Mul<f64>`
- `Mul<Vector3D>`
- `Mul<Matrix3D>`
- `Div<f64>`
- `AddAssign`
- `SubAssign`
- `MulAssign<f64>`
- `DivAssign<f64>`
- `From<Vector3D>`
- `FromStr`
- `Display`

## Availability

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