Struct speedy2d::dimen::Vector2[][src]

#[repr(C)]
pub struct Vector2<T> { pub x: T, pub y: T, }
Expand description

A vector containing two numeric values. This may represent a size or position.

Fields

x: T

The horizontal component of the vector.

y: T

The vertical component of the vector.

Implementations

Instantiates a new Vector2 from the specified horizontal and vertical components.

A constant representing a vector of zero magnitude. Each component is set to zero.

Returns the magnitude of the vector, squared.

Returns the magnitude of the vector.

Normalizes the vector so that the magnitude is 1.0. If the current magnitude of the vector is 0.0, then None is returned to avoid a division by zero.

Rotates the vector by 90 degrees in the clockwise direction.

Rotates the vector by 90 degrees in the anti-clockwise direction.

Returns a new vector with each element cast to f32, using the as operator.

Returns a new vector with each element cast to i32, using the as operator.

Returns a new vector with each element cast to u32, using the as operator.

Attempts to convert each element of this vector to an i32, returning an error if this fails.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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 conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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

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

This method tests for !=.

Round this value to the nearest integer. In the case of vectors or other types containing multiple elements, each element will be individually rounded. 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

The resulting type after applying the - operator.

Performs the - operation. 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

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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.