Struct ludomath::vec2d::Rotation [] [src]

#[repr(C)]
pub struct Rotation { pub cos: f32, pub sin: f32, }

Represents a 2D rotation or direction.

Stores the sine and cosine of the angle of rotation, which makes the rotation faster if the same angle is used multiple times. The drawbacks are memory usage, and that combining multiple rotations is more expensive.

Fields

The cosine of the angle.

The sine of the angle.

Methods

impl Rotation
[src]

[src]

Constructs a rotation from the direction of a vector.

The angle of the rotation is the angle from the positive x-axis to the vector.

[src]

Constructs a rotation of a specified angle, in radians.

[src]

Constructs a rotation of a specified angle, in degrees.

[src]

Gets the rotation from one vector to another.

Rotating the first vector by the returned rotation yields a vector with the same direction as the second vector.

[src]

Negates the angle of a rotation.

[src]

Adds the angles of two rotations together.

[src]

Subtracts the angle of one rotation from another.

Equivalent to self.add(other.negate()).

[src]

Returns the angle of rotation, in radians.

Return values are contained in (-τ/2, τ/2], aka. (-π, π].

[src]

Returns the angle of rotation, in degrees.

Return values are approximately contained in (-180, 180].

[src]

Converts the rotation to a unit vector.

[src]

Linearly interpolates the angle between two rotations.

The angle moves between the endpoints at contant speed. Like the other lerp functions, works even for t outside [0, 1]. Fairly slow, like the analogous common quaternion slerp function.

[src]

Quickly interpolates between two rotations.

Significantly faster than slerp, but doesn't have constant angle speed. This gets jerkier the further the two rotations are from eachother.

Treats the rotations as direction vectors, linearly interpolates between them, and normalizes the result to a new direction vector, which is used as the new rotation.

Trait Implementations

impl Clone for Rotation
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Rotation
[src]

impl PartialEq for Rotation
[src]

[src]

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

[src]

This method tests for !=.

impl Debug for Rotation
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Rotation

impl Sync for Rotation