pub struct Direction { /* private fields */ }
Expand description

A 2D unit vector that represents a direction

Its magnitude is always 1.0.

Example

use leafwing_input_manager::orientation::Direction;
use bevy::math::Vec2;

assert_eq!(Direction::NORTH.unit_vector(), Vec2::new(0.0, 1.0));
assert_eq!(Direction::try_from(Vec2::ONE), Ok(Direction::NORTHEAST));

assert_eq!(Direction::SOUTH * 3.0, Vec2::new(0.0, -3.0));
assert_eq!(Direction::EAST / 2.0, Vec2::new(0.5, 0.0));

Implementations

Creates a new Direction from a Vec2

The Vec2 stored internally will be normalized to have a magnitude of 1.0.

Panics

Panics if the length of the supplied vector has length zero or cannot be determined. Use try_from to get a Result instead.

Returns the raw underlying Vec2 unit vector of this direction

This will always have a length of 1.0

The direction that points straight up

The direction that points straight right

The direction that points straight down

The direction that points straight left

The direction that points halfway between up and right

The direction that points halfway between down and right

The direction that points halfway between down and left

The direction that points halfway between left and up

Trait Implementations

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

Direction::EAST is the default direction, as it is consistent with the default [Rotation]

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

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.

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.

Converts to this type from the input type.

Converts to this type from the 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

The resulting type after applying the - operator.

Performs the unary - operation. Read more

Returns the absolute distance between self and other as a Rotation Read more

Asserts that self is approximately equal to other Read more

Which RotationDirection is the shortest to rotate towards to reach target? Read more

Rotates self towards target_orientation by up to max_rotation 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 type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Return the T [ShaderType] for self. When used in [AsBindGroup] derives, it is safe to assume that all images in self exist. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Creates Self using data from the given [World]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

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

Converts the given value to a String. 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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more