#[repr(C)]
pub struct Size3D<T, U> { pub width: T, pub height: T, pub depth: T, /* private fields */ }
Expand description

A 3d size tagged with a unit.

Fields

width: T

The extent of the element in the U units along the x axis.

height: T

The extent of the element in the U units along the y axis.

depth: T

The extent of the element in the U units along the z axis.

Implementations

The same as Zero::zero() but available without importing trait.

Constructor taking scalar values.

Constructor taking scalar strongly typed lengths.

Constructor setting all components to the same value.

Tag a unitless value with units.

Return this size as an array of three elements (width, then height, then depth).

Return this size as an array of three elements (width, then height, then depth).

Return this size as a vector with width, height and depth.

Drop the units, preserving only the numeric value.

Cast the unit

Rounds each component to the nearest integer value.

This behavior is preserved for negative values (unlike the basic cast).

enum Mm {}

assert_eq!(size3::<_, Mm>(-0.1, -0.8, 0.4).round(), size3::<_, Mm>(0.0, -1.0, 0.0))

Rounds each component to the smallest integer equal or greater than the original value.

This behavior is preserved for negative values (unlike the basic cast).

enum Mm {}

assert_eq!(size3::<_, Mm>(-0.1, -0.8, 0.4).ceil(), size3::<_, Mm>(0.0, 0.0, 1.0))

Rounds each component to the biggest integer equal or lower than the original value.

This behavior is preserved for negative values (unlike the basic cast).

enum Mm {}

assert_eq!(size3::<_, Mm>(-0.1, -0.8, 0.4).floor(), size3::<_, Mm>(-1.0, -1.0, 0.0))

Returns result of multiplication of all components

Linearly interpolate between this size and another size.

Example
use euclid::size3;
use euclid::default::Size3D;

let from: Size3D<_> = size3(0.0, 10.0, -1.0);
let to:  Size3D<_> = size3(8.0, -4.0,  0.0);

assert_eq!(from.lerp(to, -1.0), size3(-8.0,  24.0, -2.0));
assert_eq!(from.lerp(to,  0.0), size3( 0.0,  10.0, -1.0));
assert_eq!(from.lerp(to,  0.5), size3( 4.0,   3.0, -0.5));
assert_eq!(from.lerp(to,  1.0), size3( 8.0,  -4.0,  0.0));
assert_eq!(from.lerp(to,  2.0), size3(16.0, -18.0,  1.0));

Cast from one numeric representation to another, preserving the units.

When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), ceil() or floor() before casting.

Fallible cast from one numeric representation to another, preserving the units.

When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), ceil() or floor() before casting.

Cast into an f32 size.

Cast into an f64 size.

Cast into an uint size, truncating decimals if any.

When casting from floating point sizes, it is worth considering whether to round(), ceil() or floor() before the cast in order to obtain the desired conversion behavior.

Cast into an u32 size, truncating decimals if any.

When casting from floating point sizes, it is worth considering whether to round(), ceil() or floor() before the cast in order to obtain the desired conversion behavior.

Cast into an i32 size, truncating decimals if any.

When casting from floating point sizes, it is worth considering whether to round(), ceil() or floor() before the cast in order to obtain the desired conversion behavior.

Cast into an i64 size, truncating decimals if any.

When casting from floating point sizes, it is worth considering whether to round(), ceil() or floor() before the cast in order to obtain the desired conversion behavior.

Returns true if all members are finite.

Computes the absolute value of each component.

For f32 and f64, NaN will be returned for component if the component is NaN.

For signed integers, ::MIN will be returned for component if the component is ::MIN.

Returns true if all components is positive and false any component is zero or negative.

Returns the size each component of which are minimum of this size and another.

Returns the size each component of which are maximum of this size and another.

Returns the size each component of which clamped by corresponding components of start and end.

Shortcut for self.max(start).min(end).

Returns vector with results of “greater than” operation on each component.

Returns vector with results of “lower than” operation on each component.

Returns true if any component of size is zero, negative or NaN.

Returns vector with results of “equal” operation on each component.

Returns vector with results of “not equal” operation on each component.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Converts this type into the (usually inferred) input type.

Converts this type into the (usually inferred) input type.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.