#[repr(C)]pub struct Vec2 {
pub x: f32,
pub y: f32,
}Fields§
§x: f32§y: f32Implementations§
Source§impl Vec2
impl Vec2
pub const ZERO: Vec2
pub const ONE: Vec2
pub const NEG_ONE: Vec2
pub const NAN: Vec2
pub const INFINITY: Vec2
pub const NEG_INFINITY: Vec2
pub const fn new(x: f32, y: f32) -> Vec2
pub const fn splat(value: f32) -> Vec2
pub const fn from_array(values: [f32; 2]) -> Vec2
pub const fn to_array(self) -> [f32; 2]
pub fn from_slice(values: &[f32]) -> Vec2
pub fn write_to_slice(self, values: &mut [f32])
pub fn is_finite(self) -> bool
pub fn is_nan(self) -> bool
pub fn dot(self, rhs: Vec2) -> f32
pub fn length_squared(self) -> f32
pub fn length_recip(self) -> f32
pub fn distance(self, other: Vec2) -> f32
pub fn distance_squared(self, other: Vec2) -> f32
Sourcepub fn try_normalize(self) -> Option<Vec2>
pub fn try_normalize(self) -> Option<Vec2>
Normalizes every finite nonzero vector, including subnormal inputs.
pub fn normalize(self) -> Vec2
pub fn normalize_or_zero(self) -> Vec2
pub fn normalize_or(self, fallback: Vec2) -> Vec2
pub fn is_normalized(self) -> bool
pub fn min(self, rhs: Vec2) -> Vec2
pub fn max(self, rhs: Vec2) -> Vec2
pub fn min_element(self) -> f32
pub fn max_element(self) -> f32
pub fn element_sum(self) -> f32
pub fn element_product(self) -> f32
pub fn abs(self) -> Vec2
pub fn signum(self) -> Vec2
pub fn floor(self) -> Vec2
pub fn ceil(self) -> Vec2
pub fn round(self) -> Vec2
pub fn trunc(self) -> Vec2
pub fn fract(self) -> Vec2
pub fn recip(self) -> Vec2
pub fn sqrt(self) -> Vec2
pub fn powf(self, exponent: f32) -> Vec2
pub fn exp(self) -> Vec2
pub fn clamp(self, min: Vec2, max: Vec2) -> Vec2
pub fn clamp_length(self, min: f32, max: f32) -> Vec2
pub fn clamp_length_max(self, max: f32) -> Vec2
pub fn clamp_length_min(self, min: f32) -> Vec2
pub fn lerp(self, rhs: Vec2, t: f32) -> Vec2
pub fn mul_add(self, multiplier: Vec2, add: Vec2) -> Vec2
pub fn abs_diff_eq(self, rhs: Vec2, tolerance: f32) -> bool
pub fn cmpeq(self, rhs: Vec2) -> BVec2
pub fn cmpne(self, rhs: Vec2) -> BVec2
pub fn cmplt(self, rhs: Vec2) -> BVec2
pub fn cmple(self, rhs: Vec2) -> BVec2
pub fn cmpgt(self, rhs: Vec2) -> BVec2
pub fn cmpge(self, rhs: Vec2) -> BVec2
pub fn select(mask: BVec2, if_true: Vec2, if_false: Vec2) -> Vec2
pub fn project_onto(self, other: Vec2) -> Vec2
pub fn reject_from(self, other: Vec2) -> Vec2
pub fn project_onto_normalized(self, normal: Vec2) -> Vec2
pub fn reject_from_normalized(self, normal: Vec2) -> Vec2
Sourcepub fn reflect(self, normal: Vec2) -> Vec2
pub fn reflect(self, normal: Vec2) -> Vec2
Reflects an incident vector about a unit surface normal.
pub fn move_towards(self, rhs: Vec2, max_distance: f32) -> Vec2
Source§impl Vec2
impl Vec2
pub const X: Vec2
pub const Y: Vec2
pub const NEG_X: Vec2
pub const NEG_Y: Vec2
pub const AXES: [Vec2; 2]
pub const fn extend(self, z: f32) -> Vec3
pub const fn perp(self) -> Vec2
pub fn perp_dot(self, rhs: Vec2) -> f32
pub fn from_angle(angle: f32) -> Vec2
pub fn to_angle(self) -> f32
Sourcepub fn angle_between(self, rhs: Vec2) -> f32
pub fn angle_between(self, rhs: Vec2) -> f32
Signed shortest angle from this direction to rhs in [-pi, pi].
Sourcepub fn rotate(self, rhs: Vec2) -> Vec2
pub fn rotate(self, rhs: Vec2) -> Vec2
Complex multiplication, useful for applying a unit 2D rotation.
pub const fn yx(self) -> Vec2
pub const fn xx(self) -> Vec2
pub const fn yy(self) -> Vec2
Trait Implementations§
Source§impl AddAssign<f32> for Vec2
impl AddAssign<f32> for Vec2
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the
+= operation. Read moreSource§impl AddAssign for Vec2
impl AddAssign for Vec2
Source§fn add_assign(&mut self, rhs: Vec2)
fn add_assign(&mut self, rhs: Vec2)
Performs the
+= operation. Read moreSource§impl DivAssign<f32> for Vec2
impl DivAssign<f32> for Vec2
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
Performs the
/= operation. Read moreSource§impl DivAssign for Vec2
impl DivAssign for Vec2
Source§fn div_assign(&mut self, rhs: Vec2)
fn div_assign(&mut self, rhs: Vec2)
Performs the
/= operation. Read moreSource§impl MulAssign<f32> for Vec2
impl MulAssign<f32> for Vec2
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
Performs the
*= operation. Read moreSource§impl MulAssign for Vec2
impl MulAssign for Vec2
Source§fn mul_assign(&mut self, rhs: Vec2)
fn mul_assign(&mut self, rhs: Vec2)
Performs the
*= operation. Read moreSource§impl SubAssign<f32> for Vec2
impl SubAssign<f32> for Vec2
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the
-= operation. Read moreSource§impl SubAssign for Vec2
impl SubAssign for Vec2
Source§fn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
Performs the
-= operation. Read moreimpl Copy for Vec2
impl StructuralPartialEq for Vec2
impl Vec2Swizzles for Vec2
Auto Trait Implementations§
impl Freeze for Vec2
impl RefUnwindSafe for Vec2
impl Send for Vec2
impl Sync for Vec2
impl Unpin for Vec2
impl UnwindSafe for Vec2
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