[][src]Struct hektor::Vec3

#[repr(C)]
pub struct Vec3 { /* fields omitted */ }

A 3-dimensional vector.

This is three f32 values, x, y, and z.

Internally, this data type is actually just a Vec4. The w coordinate value is simply ignored during calculations. Doing it like this is a slight waste of space, but gives much faster operation.

Methods

impl Vec3[src]

pub fn x(self) -> f32[src]

Gets the x component of this vector.

pub fn y(self) -> f32[src]

Gets the y component of this vector.

pub fn z(self) -> f32[src]

Gets the z component of this vector.

pub fn x_mut(&mut self) -> &mut f32[src]

&mut to the x component of this vector.

pub fn y_mut(&mut self) -> &mut f32[src]

&mut to the y component of this vector.

pub fn z_mut(&mut self) -> &mut f32[src]

&mut to the z component of this vector.

impl Vec3[src]

pub fn new(x: f32, y: f32, z: f32) -> Self[src]

Makes a new Vec3

pub fn splat(v: f32) -> Self[src]

Splats the given value across all components.

pub fn to_vec4(self, w: f32) -> Vec4[src]

Extends this 4d vec into a 4d vec with the w given.

pub fn to_vec2(self) -> Vec2[src]

Reduces this 3d vec to a 2d vec by simply forgetting the z value.

impl Vec3[src]

pub fn dot(self, rhs: Self) -> f32[src]

Dot product.

This is the sum of the component-wise multiplication of the two values. Order doesn't matter. Positive dot product means the vectors are pointing in the same general direction, zero dot product means they're perpendicular, and negative dot product means they have opposite general direction.

pub fn length(self) -> f32[src]

The length / magnitude of the vector.

  • sqrt(x^2 + y^2 + z^2)

pub fn length2(self) -> f32[src]

The squared length / magnitude of the vector.

  • x^2 + y^2 + z^2

pub fn normalize(self) -> Self[src]

Generates a new vector where the length is 1.0

Or, well, as close as it can get. Floating point, and all that.

pub fn cross(self, rhs: Self) -> Self[src]

Determines a 3D vector that's at a right angle to the two input vectors.

  • The length of the output is equal to the area of the planar section formed by the two inputs.
  • The direction of the output is right-handed perpendicular to the two inputs.

impl Vec3[src]

pub fn xx(self) -> Vec2[src]

Swizzle: obtains the xx combination

pub fn xxx(self) -> Self[src]

Swizzle: obtains the xxx combination

pub fn xxy(self) -> Self[src]

Swizzle: obtains the xxy combination

pub fn xxz(self) -> Self[src]

Swizzle: obtains the xxz combination

pub fn xy(self) -> Vec2[src]

Swizzle: obtains the xy combination

pub fn xyx(self) -> Self[src]

Swizzle: obtains the xyx combination

pub fn xyy(self) -> Self[src]

Swizzle: obtains the xyy combination

pub fn xyz(self) -> Self[src]

Swizzle: obtains the xyz combination

pub fn xz(self) -> Vec2[src]

Swizzle: obtains the xz combination

pub fn xzx(self) -> Self[src]

Swizzle: obtains the xzx combination

pub fn xzy(self) -> Self[src]

Swizzle: obtains the xzy combination

pub fn xzz(self) -> Self[src]

Swizzle: obtains the xzz combination

pub fn yx(self) -> Vec2[src]

Swizzle: obtains the yx combination

pub fn yxx(self) -> Self[src]

Swizzle: obtains the yxx combination

pub fn yxy(self) -> Self[src]

Swizzle: obtains the yxy combination

pub fn yxz(self) -> Self[src]

Swizzle: obtains the yxz combination

pub fn yy(self) -> Vec2[src]

Swizzle: obtains the yy combination

pub fn yyx(self) -> Self[src]

Swizzle: obtains the yyx combination

pub fn yyy(self) -> Self[src]

Swizzle: obtains the yyy combination

pub fn yyz(self) -> Self[src]

Swizzle: obtains the yyz combination

pub fn yz(self) -> Vec2[src]

Swizzle: obtains the yz combination

pub fn yzx(self) -> Self[src]

Swizzle: obtains the yzx combination

pub fn yzy(self) -> Self[src]

Swizzle: obtains the yzy combination

pub fn yzz(self) -> Self[src]

Swizzle: obtains the yzz combination

pub fn zx(self) -> Vec2[src]

Swizzle: obtains the zx combination

pub fn zxx(self) -> Self[src]

Swizzle: obtains the zxx combination

pub fn zxy(self) -> Self[src]

Swizzle: obtains the zxy combination

pub fn zxz(self) -> Self[src]

Swizzle: obtains the zxz combination

pub fn zy(self) -> Vec2[src]

Swizzle: obtains the zy combination

pub fn zyx(self) -> Self[src]

Swizzle: obtains the zyx combination

pub fn zyy(self) -> Self[src]

Swizzle: obtains the zyy combination

pub fn zyz(self) -> Self[src]

Swizzle: obtains the zyz combination

pub fn zz(self) -> Vec2[src]

Swizzle: obtains the zz combination

pub fn zzx(self) -> Self[src]

Swizzle: obtains the zzx combination

pub fn zzy(self) -> Self[src]

Swizzle: obtains the zzy combination

pub fn zzz(self) -> Self[src]

Swizzle: obtains the zzz combination

Trait Implementations

impl UpperExp for Vec3[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

UpperExp formats like Display, but with the upper exponent.

Passes the formatter along to the fields, so you can use any normal f32 UpperExp format arguments that you like.

impl Debug for Vec3[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Passes the formatter along to the fields, so you can use any normal f32 Debug format arguments that you like.

impl LowerExp for Vec3[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

LowerExp formats like Display, but with the lower exponent.

Passes the formatter along to the fields, so you can use any normal f32 LowerExp format arguments that you like.

impl Display for Vec3[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Display formats without labels like a 3-tuple.

Passes the formatter along to the fields, so you can use any normal f32 Display format arguments that you like.

impl Sub<Vec3> for Vec3[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<f32> for Vec3[src]

type Output = Self

The resulting type after applying the - operator.

impl Sub<Vec3> for f32[src]

type Output = Vec3

The resulting type after applying the - operator.

impl PartialEq<Vec3> for Vec3[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Add<Vec3> for Vec3[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<f32> for Vec3[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Vec3> for f32[src]

type Output = Vec3

The resulting type after applying the + operator.

impl Mul<f32> for Vec3[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vec3> for f32[src]

type Output = Vec3

The resulting type after applying the * operator.

impl Mul<Vec3> for Vec3[src]

type Output = Self

The resulting type after applying the * operator.

fn mul(self, rhs: Self) -> Self[src]

Non-mathematical component-wise multiplication (GLSL-style)

impl Mul<Vec3> for Mat3[src]

type Output = Vec3

The resulting type after applying the * operator.

impl Neg for Vec3[src]

type Output = Self

The resulting type after applying the - operator.

impl AddAssign<Vec3> for Vec3[src]

impl AddAssign<f32> for Vec3[src]

impl SubAssign<Vec3> for Vec3[src]

impl SubAssign<f32> for Vec3[src]

impl MulAssign<f32> for Vec3[src]

impl MulAssign<Vec3> for Vec3[src]

impl Index<usize> for Vec3[src]

type Output = f32

The returned type after indexing.

impl IndexMut<usize> for Vec3[src]

impl Copy for Vec3[src]

impl AsRef<[f32; 3]> for Vec3[src]

impl AsMut<[f32; 3]> for Vec3[src]

impl From<[f32; 3]> for Vec3[src]

impl From<Vec3> for [f32; 3][src]

impl Clone for Vec3[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Vec3[src]

impl Pod for Vec3[src]

impl Zeroable for Vec3[src]

fn zeroed() -> Self[src]

Calls zeroed. Read more

Auto Trait Implementations

impl Unpin for Vec3

impl Send for Vec3

impl Sync for Vec3

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]