pub struct PoincareDisk {
pub scale: f32,
}Expand description
Maps world positions into the Poincare disk model of the hyperbolic plane. Points inside the unit disk represent the entire hyperbolic plane.
Fields§
§scale: f32Scale factor mapping world units to disk radius
Implementations§
Source§impl PoincareDisk
impl PoincareDisk
pub fn new(scale: f32) -> Self
Sourcepub fn to_disk(&self, world_pos: Vec2) -> Vec2
pub fn to_disk(&self, world_pos: Vec2) -> Vec2
Convert a world position to Poincare disk coordinates. Uses the exponential map: disk_pos = tanh(|p|/2) * (p/|p|)
Sourcepub fn from_disk(&self, disk_pos: Vec2) -> Vec2
pub fn from_disk(&self, disk_pos: Vec2) -> Vec2
Convert a Poincare disk coordinate back to world position. Inverse of to_disk: world = 2 * atanh(|d|) * (d/|d|) * scale
Sourcepub fn hyperbolic_distance(&self, a: Vec2, b: Vec2) -> f32
pub fn hyperbolic_distance(&self, a: Vec2, b: Vec2) -> f32
Compute the hyperbolic distance between two points in the Poincare disk. d(a,b) = acosh(1 + 2|a-b|^2 / ((1-|a|^2)(1-|b|^2)))
Sourcepub fn geodesic(&self, a: Vec2, b: Vec2, steps: usize) -> Vec<Vec2>
pub fn geodesic(&self, a: Vec2, b: Vec2, steps: usize) -> Vec<Vec2>
Compute a geodesic (hyperbolic line) between two points on the disk. In the Poincare model geodesics are circular arcs orthogonal to the boundary, or diameters through the origin.
Sourcepub fn mobius_transform(&self, z: Vec2, a: Vec2) -> Vec2
pub fn mobius_transform(&self, z: Vec2, a: Vec2) -> Vec2
Apply a Mobius transform (isometry of the Poincare disk). T_a(z) = (z + a) / (1 + conj(a)*z) treating Vec2 as complex numbers.
Auto Trait Implementations§
impl Freeze for PoincareDisk
impl RefUnwindSafe for PoincareDisk
impl Send for PoincareDisk
impl Sync for PoincareDisk
impl Unpin for PoincareDisk
impl UnsafeUnpin for PoincareDisk
impl UnwindSafe for PoincareDisk
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.