[−][src]Struct hektor::Vec2
A 2-dimensional vector.
This is two f32
values, x
and y
.
Methods
impl Vec2
[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 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.
impl Vec2
[src]
pub fn new(x: f32, y: f32) -> Self
[src]
Makes a new Vec2
pub fn splat(v: f32) -> Self
[src]
Splats the given value across all components.
pub fn to_vec3(self, z: f32) -> Vec3
[src]
Extends this 2d vec into a 3d vec with the z
given.
impl Vec2
[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)
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.
impl Vec2
[src]
pub fn xx(self) -> Self
[src]
Swizzle: obtains the xx
combination
pub fn xy(self) -> Self
[src]
Swizzle: obtains the xy
combination
pub fn yx(self) -> Self
[src]
Swizzle: obtains the yx
combination
pub fn yy(self) -> Self
[src]
Swizzle: obtains the yy
combination
Trait Implementations
impl Debug for Vec2
[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 UpperExp for Vec2
[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 Display for Vec2
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Display formats without labels like a 2-tuple.
Passes the formatter along to the fields, so you can use any normal f32
Display format arguments that you like.
impl LowerExp for Vec2
[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 Sub<Vec2> for Vec2
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
impl Sub<f32> for Vec2
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: f32) -> Self
[src]
impl Sub<Vec2> for f32
[src]
type Output = Vec2
The resulting type after applying the -
operator.
fn sub(self, rhs: Vec2) -> Vec2
[src]
impl PartialEq<Vec2> for Vec2
[src]
impl Add<Vec2> for Vec2
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
impl Add<f32> for Vec2
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: f32) -> Self
[src]
impl Add<Vec2> for f32
[src]
type Output = Vec2
The resulting type after applying the +
operator.
fn add(self, rhs: Vec2) -> Vec2
[src]
impl Mul<f32> for Vec2
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f32) -> Self
[src]
impl Mul<Vec2> for f32
[src]
type Output = Vec2
The resulting type after applying the *
operator.
fn mul(self, rhs: Vec2) -> Vec2
[src]
impl Mul<Vec2> for Vec2
[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<Vec2> for Mat2
[src]
type Output = Vec2
The resulting type after applying the *
operator.
fn mul(self, v2: Vec2) -> Vec2
[src]
impl Neg for Vec2
[src]
impl AddAssign<Vec2> for Vec2
[src]
fn add_assign(&mut self, rhs: Self)
[src]
impl AddAssign<f32> for Vec2
[src]
fn add_assign(&mut self, rhs: f32)
[src]
impl SubAssign<Vec2> for Vec2
[src]
fn sub_assign(&mut self, rhs: Self)
[src]
impl SubAssign<f32> for Vec2
[src]
fn sub_assign(&mut self, rhs: f32)
[src]
impl MulAssign<f32> for Vec2
[src]
fn mul_assign(&mut self, rhs: f32)
[src]
impl MulAssign<Vec2> for Vec2
[src]
fn mul_assign(&mut self, rhs: Self)
[src]
impl Index<usize> for Vec2
[src]
impl IndexMut<usize> for Vec2
[src]
impl Copy for Vec2
[src]
impl AsRef<[f32; 2]> for Vec2
[src]
impl AsMut<[f32; 2]> for Vec2
[src]
impl From<[f32; 2]> for Vec2
[src]
impl From<Vec2> for [f32; 2]
[src]
impl Clone for Vec2
[src]
fn clone(&self) -> Vec2
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Vec2
[src]
impl Pod for Vec2
[src]
impl Zeroable for Vec2
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,