pub struct Point3D<T> {
pub x: T,
pub y: T,
pub z: T,
}
Expand description
Represents a 3-dimensional point in space. In this crates context mostly used for displaying points of vertices.
It can be either created by using the method new
or by using the point!
macro.
§Example
use picocadrs::assets::Point3D;
use picocadrs::point;
let mut point = Point3D::new(2, 4, -1);
assert_eq!(point.x, 2);
assert_eq!(point.y, 4);
assert_eq!(point.z, -1);
assert_eq!(point, point!(2, 4, -1));
point.set(1, 2, 3);
assert_eq!(point, point!(1, 2, 3));
assert_eq!(point + point, point!(2, 4, 6));
assert_eq!(point - point, point!(0, 0, 0));
Fields§
§x: T
§y: T
§z: T
Implementations§
source§impl<T> Point3D<T>
impl<T> Point3D<T>
sourcepub fn new(x: T, y: T, z: T) -> Point3D<T>
pub fn new(x: T, y: T, z: T) -> Point3D<T>
Used to create new points in a 3-dimensional space.
Takes the points x
, y
and z
coordinates as arguments.
A simpler way to create new Point3D
s is to use the point!
macro.
§Example
use picocadrs::assets::Point3D;
use picocadrs::point;
let point = Point3D::new(2, 4, -1);
assert_eq!(point.x, 2);
assert_eq!(point.y, 4);
assert_eq!(point.z, -1);
assert_eq!(point, point!(2, 4, -1));
sourcepub fn set(&mut self, x: T, y: T, z: T)
pub fn set(&mut self, x: T, y: T, z: T)
Sets the points coordinates to the ones given.
§Example
use picocadrs::assets::Point3D;
let mut point = Point3D::new(2, 4, -1);
assert_eq!(point.x, 2);
assert_eq!(point.y, 4);
assert_eq!(point.z, -1);
point.set(-3, 4, 2);
assert_eq!(point.x, -3);
assert_eq!(point.y, 4);
assert_eq!(point.z, 2);
Trait Implementations§
source§impl<T: PartialEq> PartialEq for Point3D<T>
impl<T: PartialEq> PartialEq for Point3D<T>
source§impl<T: Sub<Output = T>> Sub for Point3D<T>
impl<T: Sub<Output = T>> Sub for Point3D<T>
source§impl TryFrom<Table<'_>> for Point3D<f64>
impl TryFrom<Table<'_>> for Point3D<f64>
impl<T: Copy> Copy for Point3D<T>
impl<T: Eq> Eq for Point3D<T>
impl<T> StructuralPartialEq for Point3D<T>
Auto Trait Implementations§
impl<T> Freeze for Point3D<T>where
T: Freeze,
impl<T> RefUnwindSafe for Point3D<T>where
T: RefUnwindSafe,
impl<T> Send for Point3D<T>where
T: Send,
impl<T> Sync for Point3D<T>where
T: Sync,
impl<T> Unpin for Point3D<T>where
T: Unpin,
impl<T> UnwindSafe for Point3D<T>where
T: UnwindSafe,
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