#quaternions #cartesian #spherical #bridge #convert #xyz #3d #coord-system

bin+lib uvoxxyz

Bridge between UVoxID spherical space and Cartesian XYZ + quaternions

3 unstable releases

Uses new Rust 2024

0.2.0 Sep 23, 2025
0.1.1 Sep 23, 2025
0.1.0 Sep 21, 2025

#7 in #spherical

Download history 336/week @ 2025-09-20 62/week @ 2025-09-27 15/week @ 2025-10-04 8/week @ 2025-10-11 14/week @ 2025-10-18 5/week @ 2025-10-25

67 downloads per month
Used in chronovox

MIT license

12KB
178 lines

uvoxxyz

CI

Created by JDPlumbing

📦 Installation

cargo install uvoxxyz

Bridge between spherical UvoxId coordinates and Cartesian space, with quaternion support.

uvoxxyz lets you:

  • Convert between uvoxid spherical IDs and 3D Cartesian coordinates.
  • Choose between math convention (X/Y horizontal, Z up) and graphics convention (X/Z horizontal, Y up).
  • Apply quaternions for orientation and rotation in either system.

Example

use uvoxid::UvoxId;
use uvoxxyz::types::{CoordSystem, Cartesian, Quaternion};
use uvoxxyz::convert::*;

fn main() {
    // A UvoxId located at radius=1m, lat=0, lon=0
    let id = UvoxId::new(0, 1_000_000, 0, 0);

    // Convert to Cartesian (math convention)
    let cart = id.to_cartesian(CoordSystem::Math);
    println!("Cartesian: ({}, {}, {})", cart.x, cart.y, cart.z);

    // Rotate by 90° around Z
    let q = Quaternion::from_axis_angle(
        Cartesian { x: 0.0, y: 0.0, z: 1.0 },
        std::f64::consts::FRAC_PI_2
    );
    let rotated = q.rotate(cart);
    println!("Rotated: ({}, {}, {})", rotated.x, rotated.y, rotated.z);

    // Convert back to UvoxId
    let round_trip = UvoxId::from_cartesian(rotated, CoordSystem::Math, 0);
    println!("Back to UvoxId: {}", round_trip);
}

Features

  • 🧭 UvoxId → Cartesian and back
  • 🔄 Support for math and graphics axis conventions
  • 🎛️ Quaternion math (normalize, multiply, rotate)
  • ⚡ Nanosecond-level benchmarks (sub-20ns conversions)

  • uvoxid: Hierarchical spherical integer coordinate system
  • geospec: Geometric shapes and inference utilities

License

MIT or Apache-2.0, at your option.


Minimum Rust Version

Rust 1.70+

Dependencies

~8MB
~219K SLoC