Struct sfml::system::Vector3 [] [src]

#[repr(C)]
pub struct Vector3<T> { pub x: T, pub y: T, pub z: T, }

Utility type for manipulating 3-dimensional vectors.

Vector3 is a simple type that defines a mathematical vector with three coordinates (x, y and z).

It can be used to represent anything that has three dimensions: a size, a point, a velocity, etc.

The type parameter T is the type of the coordinates.

You generally don't have to care about the generic form (Vector3<T>), the most common specializations have special type aliases:

  • Vector3<f32> is Vector3f
  • Vector3<i32> is Vector3i

The Vector3 type has a small and simple interface, its x and y members can be accessed directly (there are no accessors like set_x(), get_x()) and it contains no mathematical function like dot product, cross product, length, etc.

Usage example

let mut v1 = Vector3f::new(16.5, 24.0, -8.2);
v1.x = 18.2;
let y = v1.y;
let z = v1.z;

let v2 = v1 * 5.0;
let v3 = v1 + v2;

assert_ne!(v2, v3);

Note: for 2-dimensional vectors, see Vector2.

Fields

X coordinate of the vector.

Y coordinate of the vector.

Z coordinate of the vector.

Methods

impl<T> Vector3<T>
[src]

[src]

Create a new Vector3f with the given values.

Trait Implementations

impl<T: Clone> Clone for Vector3<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: PartialOrd> PartialOrd for Vector3<T>
[src]

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

impl<T: PartialEq> PartialEq for Vector3<T>
[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<T: Debug> Debug for Vector3<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: Copy> Copy for Vector3<T>
[src]

impl<T: Default> Default for Vector3<T>
[src]

[src]

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

impl<T: Add + Copy> Add<T> for Vector3<T>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T: Sub + Copy> Sub<T> for Vector3<T>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<T: Mul + Copy> Mul<T> for Vector3<T>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: Div + Copy> Div<T> for Vector3<T>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: Add> Add for Vector3<T>
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<T: AddAssign> AddAssign for Vector3<T>
[src]

[src]

Performs the += operation.

impl<T: Sub> Sub for Vector3<T>
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<T: SubAssign> SubAssign for Vector3<T>
[src]

[src]

Performs the -= operation.

impl<T: Mul> Mul for Vector3<T>
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<T: MulAssign + Copy> MulAssign<T> for Vector3<T>
[src]

[src]

Performs the *= operation.

impl<T: Div> Div for Vector3<T>
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<T: DivAssign + Copy> DivAssign<T> for Vector3<T>
[src]

[src]

Performs the /= operation.

impl<T: Neg<Output = T>> Neg for Vector3<T>
[src]

The resulting type after applying the - operator.

[src]

Performs the unary - operation.

impl<T> From<(T, T, T)> for Vector3<T>
[src]

[src]

Constructs a Vector3 from (x, y, z).