Struct lowdim::Vec2d[][src]

pub struct Vec2d<S = i64>(_)
where
    S: Integer
;
Expand description

A two-dimensional discrete vector.

Implementations

Creates a new 2d-vector from its coordinates.

Returns the x coordinate of the vector.

Examples
let v = v2d(2, 3);
assert_eq!(2, v.x());

Returns the y coordinate of the vector.

Examples
let v = v2d(2, 3);
assert_eq!(3, v.y());

Returns true if the vector points towards positive x.

That is, among the vectors pointing in both directions along the coordinate axes, the one pointing towards positive x is closest to this vector. Or to put it more concretely, the x coordinate of the vector is positive, and its absolute value is greater than that of the other coordinates.

Examples
let v = v2d(3, 2);
assert!(v.is_towards_pos_x());
let v = v2d(3, -2);
assert!(v.is_towards_pos_x());
let v = v2d(-3, -2);
assert!(!v.is_towards_pos_x());
let v = v2d(3, 3);
assert!(!v.is_towards_pos_x());

Returns true if the vector points towards negative x.

That is, among the vectors pointing in both directions along the coordinate axes, the one pointing towards negative x is closest to this vector. Or to put it more concretely, the x coordinate of the vector is negative, and its absolute value is greater than that of the other coordinates.

Examples
let v = v2d(-3, 2);
assert!(v.is_towards_neg_x());

Returns true if the vector points towards positive y.

See Vec2d::is_towards_pos_x for more details.

Examples
let v = v2d(2, 3);
assert!(v.is_towards_pos_y());

Returns true if the vector points towards negative y.

See Vec2d::is_towards_neg_x for more details.

Examples
let v = v2d(2, -3);
assert!(v.is_towards_neg_y());

Returns a vector obtained by rotating this vector left by a right angle.

Examples
let v = v2d(2, 3);
assert_eq!(v2d(-3, 2), v.rotate_left());

Returns a vector obtained by rotating this vector right by a right angle.

Examples
let v = v2d(2, 3);
assert_eq!(v2d(3, -2), v.rotate_right());

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

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

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Feeds this value into the given Hasher. Read more

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

The returned type after indexing.

Performs the indexing (container[index]) 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

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

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

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

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

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

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

The resulting type after applying the - operator.

Performs the unary - 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 !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. 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

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Performs the -= operation. Read more

The L1, taxicab or Manhatten norm.

The maximum, Chebychev or L∞ norm.

Creates a vector of the 8 vectors with L∞ norm equal to 1.

The dimension of the vectors in this type.

Create a vector from a function which computes the coordinates. Read more

Returns the lexicographic total ordering for this and another vector. Read more

Creates the zero vector.

Returns true if a vector is the zero vector.

Apply min by component

Apply max by component

Signum by component. Read more

Creates a vector of the unit vectors.

Creates a vector of the vectors to orthogonal neighbours. 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 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)

recently added

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.