Skip to main content

Crate rebirth_ik

Crate rebirth_ik 

Source
Expand description

§rebirth-ik

Inverse kinematics in safe Rust — a rebirth of the abandoned C library TheComet/ik (MIT, © 2017 Alex Murray).

  • Skeleton + Fabrik: FABRIK over arbitrary bone trees with several effectors, effector weights, joint constraints and optional joint rotations.
  • solve_chain: allocation-free FABRIK for a single chain of points (no_std).
  • one_bone / two_bone: closed-form solvers (with pole vector for knees and elbows).
  • rayon feature: [solve_chains_par] for crowds.
use rebirth_ik::*;

// a three-bone arm hanging up from the origin
let mut skel = Skeleton::new();
let root = skel.add_root(Vec3::ZERO);
let a = skel.add_child(root, Vec3::new(0.0, 1.0, 0.0));
let b = skel.add_child(a, Vec3::new(0.0, 1.0, 0.0));
let hand = skel.add_child(b, Vec3::new(0.0, 1.0, 0.0));
skel.set_effector(hand, Effector::new(Vec3::new(1.5, 1.5, 0.0)));

let mut solver = Fabrik::new(&skel, Config::default());
let info = solver.solve(&mut skel);
assert!(info.converged);
assert!(skel.global_position(hand).distance(Vec3::new(1.5, 1.5, 0.0)) < 1e-2);

Re-exports§

pub use analytic::one_bone;
pub use analytic::segment_rotation;
pub use analytic::two_bone;
pub use chain::Chain;
pub use chain::ChainTree;
pub use constraint::Constraint;
pub use math::Quat;
pub use math::Vec3;
pub use single::segment_lengths;
pub use single::solve_chain;
pub use single::ChainResult;
pub use single::solve_chains;
pub use single::ChainBuf;
pub use skeleton::Effector;
pub use skeleton::EffectorFlags;
pub use skeleton::Node;
pub use skeleton::NodeId;
pub use skeleton::Skeleton;
pub use solver::Config;
pub use solver::Fabrik;
pub use solver::SolveInfo;

Modules§

analytic
Closed-form solvers for chains of one and two bones. Exact, branch-light and allocation-free.
chain
Splits a bone tree into chains between effectors and branching points.
constraint
Joint limits used by the tree solver.
math
Minimal f32 vector and quaternion math. No allocation, no_std-friendly.
single
Allocation-free FABRIK on a plain slice of points, plus the batch helpers built on it.
skeleton
The bone tree: nodes with local transforms, optional effectors and constraints.
solver
FABRIK for whole bone trees with several effectors.