CartesianTree

Crates.ioCartesianTree
lib.rsCartesianTree
version0.3.0
created_at2025-08-06 17:22:37.626179+00
updated_at2025-12-05 16:54:00.645048+00
descriptionBuild hierarchical Cartesian coordinate systems to easily transform poses.
homepagehttps://github.com/Kn0g/cartesian-tree
repositoryhttps://github.com/Kn0g/cartesian-tree
max_upload_size
id1784096
size92,727
(Kn0g)

documentation

README

cartesian-tree

cartesian-tree is a library for managing and transforming poses in a tree-structured hierarchy of 3D coordinate frames in rust as well as python.

Key ideas

  • Tree Structure: Frames form a tree where each frame defines its position and orientation relative to a parent frame.
  • Poses and Transformations: A Pose represents a position + orientation in a frame. Easily transform poses between frames of the same tree.
  • Unified Rotations: Supports quaternions and roll-pitch-yaw (RPY) interchangeably.
  • Lazy Operations: Quick adjustments like translations (+ x(1.0)) or rotations (* rz(PI/4)).

Installation

The project can be found on crates.io and pypi.org

Usage

Rust:

use cartesian_tree::{Frame, Pose};
use nalgebra::{Vector3, UnitQuaternion};

fn main() {
    // Create root frame
    let world = Frame::new_origin("world");

    // Add a child frame
    let child = world.add_child(
        "child",
        Vector3::new(1.0, 0.0, 0.0),
        UnitQuaternion::from_euler_angles(0.0, 0.0, std::f64::consts::FRAC_PI_2),
    ).unwrap();

    // Create a pose in the world frame
    let pose = world.add_pose(Vector3::new(0.0, 1.0, 0.0), UnitQuaternion::identity());

    // Transform the pose to the child frame
    let pose_in_child = pose.in_frame(&child).unwrap();

    println!("Pose in child: {:?}", pose_in_base.transformation());

Python:

from cartesian_tree import Frame, Rotation, Vector3

# Create root frame
world = Frame("world")

# Add a child frame
child = world.add_child(
    "child",
    Vector3(1.0, 0.0, 0.0),
    Rotation.identity()
)

# Create a pose in the world frame
pose = world.add_pose(
    Vector3(0.0, 1.0, 0.0), Rotation.identity()
)

# Transform the pose to the child frame
pose_in_child = pose.in_frame(child)

print(f"Pose in child: {pose_in_child}")
Commit count: 0

cargo fmt