pub struct Point3D { /* private fields */ }Expand description
A 3D point encoded with dodecets
Each coordinate (x, y, z) is stored as a dodecet (12 bits).
§Example
use dodecet_encoder::geometric::Point3D;
let point = Point3D::new(0x100, 0x200, 0x300);
assert_eq!(point.x(), 0x100);Implementations§
Source§impl Point3D
impl Point3D
Sourcepub fn normalized(&self) -> (f64, f64, f64)
pub fn normalized(&self) -> (f64, f64, f64)
Convert to normalized floating point coordinates [0.0, 1.0]
§Example
use dodecet_encoder::geometric::Point3D;
let point = Point3D::new(0x800, 0x800, 0x800);
let (nx, ny, nz) = point.normalized();
assert!((nx - 0.5).abs() < 0.001);Sourcepub fn signed(&self) -> (i16, i16, i16)
pub fn signed(&self) -> (i16, i16, i16)
Convert to signed coordinates [-2048, 2047]
§Example
use dodecet_encoder::geometric::Point3D;
let point = Point3D::new(0x800, 0x000, 0x7FF);
let (sx, sy, sz) = point.signed();
assert_eq!(sx, -2048);
assert_eq!(sy, 0);
assert_eq!(sz, 2047);Sourcepub fn distance_to(&self, other: &Point3D) -> f64
pub fn distance_to(&self, other: &Point3D) -> f64
Calculate distance to another point
§Example
use dodecet_encoder::geometric::Point3D;
let p1 = Point3D::new(0x000, 0x000, 0x000);
let p2 = Point3D::new(0x100, 0x000, 0x000);
let dist = p1.distance_to(&p2);
assert!((dist - 256.0).abs() < 0.1);Sourcepub fn to_hex_string(&self) -> String
pub fn to_hex_string(&self) -> String
Convert to hex string
Sourcepub fn from_hex_str(s: &str) -> Result<Self>
pub fn from_hex_str(s: &str) -> Result<Self>
Parse from hex string
Trait Implementations§
impl Eq for Point3D
impl StructuralPartialEq for Point3D
Auto Trait Implementations§
impl Freeze for Point3D
impl RefUnwindSafe for Point3D
impl Send for Point3D
impl Sync for Point3D
impl Unpin for Point3D
impl UnsafeUnpin for Point3D
impl UnwindSafe for Point3D
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