Struct ludomath::vec2d::Vector [] [src]

#[repr(C)]
pub struct Vector { pub x: f32, pub y: f32, }

Represents a cartesian vector in the 2D euclidean plane.

Fields

The X component of the vector.

The Y component of the vector.

Methods

impl Vector
[src]

[src]

Constructs a new vector.

[src]

Constructs a unit-length vector with a certain angle in radians.

[src]

Constructs a unit-length vector with a certain angle in degrees.

[src]

Constructs a vector of a certain magnitude and angle (in radians).

[src]

Constructs a vector of a certain magnitude and angle (in degrees).

[src]

Computes the magnitude/length of a vector.

[src]

Computes the dot product of two vectors.

[src]

Computes the component-wise product of two vectors.

[src]

Computes the component-wise product of two vectors, assigning the result to the first one.

[src]

Rotates a vector by a Rotation struct.

[src]

Rotates a vector, mutating it.

[src]

Rotates a vector by an angle in radians.

[src]

Rotates a vector by an angle in radians, mutating it.

[src]

Rotates a vector by an angle in degrees.

[src]

Rotates a vector by an angle in degrees, mutating it.

[src]

Normalizes a vector to unit length.

If the vector is zero, returns (1, 0).

[src]

Sets a vector to unit length.

If the vector is zero, sets to (1, 0).

[src]

Computes the euclidean distance between two vectors.

[src]

Computes the grid-based distance between two vectors.

This is the length of the shortest path between the vectors, if the only movement allowed is parallel to the x- or y-axis.

[src]

Computes the angle between a vector and the positive x-axis, in radians.

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

[src]

Computes the angle between a vector and the positive x-axis, in degrees.

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

[src]

Computes the angle between two vectors, in radians.

Rotating the first vector by the resulting angle will give it the same angle as the second.

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

[src]

Computes the angle between two vectors, in degrees.

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

[src]

Calls a function on each component of a vector, returning the result as a new vector.

[src]

Sets each component to the result of calling a function on the component's value.

[src]

Linearly interpolates from one vector to another by t.

t < 0 or t > 1 gives results outside the rectangular bounds of the vectors.

[src]

Returns true if self is within the (inclusive) bounds of the rectangle defined by two vertices.

[src]

Clamps a vector to within the (inclusive) bounds of the rectangle defined by two vertices.

[src]

Reinterprets the x- and y-components of a vector as a point.

[src]

Converts a OpenGL-style vec2 to a Vector.

Optimizes into a simple copy, since the types have the same layout.

[src]

Converts a Vector to a OpenGL-style vec2.

Optimizes into a simple copy, since the types have the same layout.

[src]

Converts a Vector to a OpenGL-style vec3.

The result is padded to [x, y, 0].

[src]

Converts a Vector to a OpenGL-style vec4.

The result is padded to [x, y, 0, 0].

[src]

Reinterprets a slice of vec2s as Vectors.

Does not allocate a new array, only changes the type of the pointer.

[src]

Reinterprets a slice of Vectors as vec2s.

Does not allocate a new array, only changes the type of the pointer.

Trait Implementations

impl Clone for Vector
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Vector
[src]

impl Default for Vector
[src]

[src]

Returns the "default value" for a type. Read more

impl PartialEq for Vector
[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 Vector
[src]

[src]

Formats the value using the given formatter. Read more

impl Transformation<Vector> for Transform
[src]

[src]

Returns a transformed copy of an object. Read more

[src]

Transforms an object by the inverse of a transformation. Read more

[src]

Transforms an object, mutating it.

[src]

Transforms an object by the inverse of a transformation. Read more

impl Add<Vector> for Vector
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl Add<Vector> for Point
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl Add<Point> for Vector
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl Sub<Vector> for Vector
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl Sub<Vector> for Point
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl AddAssign<Vector> for Vector
[src]

[src]

Performs the += operation.

impl AddAssign<Vector> for Point
[src]

[src]

Performs the += operation.

impl SubAssign<Vector> for Vector
[src]

[src]

Performs the -= operation.

impl SubAssign<Vector> for Point
[src]

[src]

Performs the -= operation.

impl Mul<f32> for Vector
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl Mul<Vector> for f32
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl MulAssign<f32> for Vector
[src]

[src]

Performs the *= operation.

impl Div<f32> for Vector
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl DivAssign<f32> for Vector
[src]

[src]

Performs the /= operation.

impl Neg for Vector
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

Auto Trait Implementations

impl Send for Vector

impl Sync for Vector