diff --git a/src/bin/flat/main.rs b/src/bin/flat/main.rs index e887958..23596a9 100644 --- a/src/bin/flat/main.rs +++ b/src/bin/flat/main.rs @@ -148,15 +148,10 @@ fn rel_to_abs(space: &impl Metric, base: &Location, rel: Vec2, steps: usize) -> } /// Converts a position and a rotation to a [Location]. Only the X direction is preserved from `rot` to ensure the resulting Location describes an orthonormal coordinate system. -/// -/// Mathematically, returned `rot` is `M^-1 * orthonormalize(M * rot)` where `M^2` is the metric tensor. fn put_object(space: &impl Metric, pos: Vec2, rot: Mat2) -> Location { - let x_dir = rot.x_axis; let metric_sqrt = Mat2::from(space.sqrt_at(pos)); let metric_inv_sqrt = Mat2::from(space.sqrt_at(pos).inverse()); - let fx = (metric_sqrt * x_dir).normalize(); - let fy = vec2(-fx.y, fx.x); // TODO: respect orientation of `rot` - let rot = metric_inv_sqrt * mat2(fx, fy); + let rot = metric_inv_sqrt * (metric_sqrt * rot).orthonormalize(); Location { pos, rot } }