Struct rustic_zen::geom::Vector
source · pub struct Vector {
pub x: f64,
pub y: f64,
}
Expand description
A standard 2D vector implementaion.
Fields§
§x: f64
§y: f64
Implementations§
source§impl Vector
impl Vector
sourcepub fn new(x: f64, y: f64) -> Self
pub fn new(x: f64, y: f64) -> Self
Create new vector. This is just a helper given the fields are public.
sourcepub fn normalized(&self) -> Vector
pub fn normalized(&self) -> Vector
returns a copy of this vector with a length of 1
sourcepub fn scale_e(&self, sx: f64, sy: f64) -> Vector
pub fn scale_e(&self, sx: f64, sy: f64) -> Vector
element wise scaling with seperate x and y scaling factors
sourcepub fn rotate(&self, theta: f64) -> Vector
pub fn rotate(&self, theta: f64) -> Vector
apply a rotation matrix constructed around theta
to this vector
sourcepub fn reflect(&self, normal: &Vector) -> Vector
pub fn reflect(&self, normal: &Vector) -> Vector
Caluate a normal reflection of this vector as a direction vector
against a surface with a normal vector of normal
.
§Parameters:
- self: a
Vector
representing the direction to be relected. - normal: a
Vector
representing the normal of the surface being reflected off.
Neither vector needs to be normalised.
Trait Implementations§
source§impl PartialEq for Vector
impl PartialEq for Vector
source§impl PartialOrd for Vector
impl PartialOrd for Vector
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Vector
impl StructuralPartialEq for Vector
Auto Trait Implementations§
impl Freeze for Vector
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnwindSafe for Vector
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more