#[repr(C)]pub struct NiPoint3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
Expand description
3D vector representation.
Fields§
§x: f32
§y: f32
§z: f32
Implementations§
Source§impl NiPoint3
impl NiPoint3
Sourcepub const fn new(x: f32, y: f32, z: f32) -> Self
pub const fn new(x: f32, y: f32, z: f32) -> Self
Creates a new NiPoint3
from x, y, and z coordinates.
§Example
let point = NiPoint3::new(1.0, 2.0, 3.0);
assert_eq!(point.x, 1.0);
Sourcepub fn dot(&self, other: &Self) -> f32
pub fn dot(&self, other: &Self) -> f32
Computes the dot product with another NiPoint3
.
§Example
let a = NiPoint3::new(1.0, 2.0, 3.0);
let b = NiPoint3::new(4.0, 5.0, 6.0);
assert_eq!(a.dot(&b), 32.0);
Sourcepub fn cross(&self, other: &Self) -> Self
pub fn cross(&self, other: &Self) -> Self
Computes the cross product with another NiPoint3
.
§Example
let a = NiPoint3::new(1.0, 0.0, 0.0);
let b = NiPoint3::new(0.0, 1.0, 0.0);
let cross = a.cross(&b);
assert_eq!(cross, NiPoint3::new(0.0, 0.0, 1.0));
Sourcepub fn length(&self) -> f32
pub fn length(&self) -> f32
Computes the length (magnitude) of the vector.
§Example
let v = NiPoint3::new(3.0, 4.0, 0.0);
assert_eq!(v.length(), 5.0);
Sourcepub fn sqr_length(&self) -> f32
pub fn sqr_length(&self) -> f32
Returns the squared length of the vector.
Sourcepub fn distance(&self, other: &Self) -> f32
pub fn distance(&self, other: &Self) -> f32
Computes the distance to another NiPoint3
.
§Example
let a = NiPoint3::new(1.0, 2.0, 3.0);
let b = NiPoint3::new(4.0, 6.0, 3.0);
assert_eq!(a.distance(&b), 5.0);
Sourcepub fn squared_distance(&self, other: &Self) -> f32
pub fn squared_distance(&self, other: &Self) -> f32
Computes the squared distance to another NiPoint3
.
Sourcepub fn unitize(&mut self) -> f32
pub fn unitize(&mut self) -> f32
Normalizes the vector in place and returns its original length.
§Example
let mut v = NiPoint3::new(3.0, 4.0, 0.0);
let len = v.unitize();
assert_eq!(len, 5.0);
assert_eq!(v, NiPoint3::new(0.6, 0.8, 0.0));
Sourcepub fn unit_cross(&self, other: &Self) -> Self
pub fn unit_cross(&self, other: &Self) -> Self
Computes the unit cross product with another NiPoint3
.
§Example
let a = NiPoint3::new(1.0, 0.0, 0.0);
let b = NiPoint3::new(0.0, 1.0, 0.0);
let unit_cross = a.unit_cross(&b);
assert_eq!(unit_cross, NiPoint3::new(0.0, 0.0, 1.0));
Trait Implementations§
Source§impl AddAssign for NiPoint3
impl AddAssign for NiPoint3
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moreSource§impl DivAssign<f32> for NiPoint3
impl DivAssign<f32> for NiPoint3
Source§fn div_assign(&mut self, scalar: f32)
fn div_assign(&mut self, scalar: f32)
Performs the
/=
operation. Read moreSource§impl Mul<NiPoint3> for NiTransform
impl Mul<NiPoint3> for NiTransform
Source§impl MulAssign<f32> for NiPoint3
impl MulAssign<f32> for NiPoint3
Source§fn mul_assign(&mut self, scalar: f32)
fn mul_assign(&mut self, scalar: f32)
Performs the
*=
operation. Read moreSource§impl PartialOrd for NiPoint3
impl PartialOrd for NiPoint3
Source§impl SubAssign for NiPoint3
impl SubAssign for NiPoint3
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for NiPoint3
impl StructuralPartialEq for NiPoint3
Auto Trait Implementations§
impl Freeze for NiPoint3
impl RefUnwindSafe for NiPoint3
impl Send for NiPoint3
impl Sync for NiPoint3
impl Unpin for NiPoint3
impl UnwindSafe for NiPoint3
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