diff --git a/src/bin/flat/tube/mod.rs b/src/bin/flat/tube/mod.rs index b5cac7a..41e6553 100644 --- a/src/bin/flat/tube/mod.rs +++ b/src/bin/flat/tube/mod.rs @@ -230,9 +230,10 @@ mod coords { impl FlatCoordinateSystem for InnerCS { fn flat_to_global(&self, loc: Location) -> Location { + let pos = self.flat_to_global(loc.pos); Location { - pos: self.flat_to_global(loc.pos), - rot: Mat2::from(self.0.sqrt_at(loc.pos).inverse()) * loc.rot, + pos, + rot: Mat2::from(self.0.sqrt_at(pos).inverse()) * loc.rot, } } @@ -280,9 +281,10 @@ mod coords { impl FlatCoordinateSystem for OuterCS { fn flat_to_global(&self, loc: Location) -> Location { + let pos = self.flat_to_global(loc.pos); Location { - pos: self.flat_to_global(loc.pos), - rot: Mat2::from(self.0.sqrt_at(loc.pos).inverse()) * loc.rot, + pos, + rot: Mat2::from(self.0.sqrt_at(pos).inverse()) * loc.rot, } } @@ -340,6 +342,7 @@ mod coords { check_range("global", pos_global, range_global, "flat", pos_flat, range_flat); assert_eq_at!(pos_global, region.global_to_flat(Location { pos: pos_global, rot: Mat2::IDENTITY }).pos, pos_flat); assert_eq_at!(pos_global, region.flat_to_global(pos_flat), pos_global); + assert_eq_at!(pos_global, region.flat_to_global(region.global_to_flat(Location { pos: pos_global, rot: Mat2::IDENTITY })).rot, Mat2::IDENTITY); } } for x in linspace(range_flat.0.x, range_flat.1.x, 20) { @@ -349,6 +352,7 @@ mod coords { check_range("flat", pos_flat, range_flat, "global", pos_global, range_global); assert_eq_at!(pos_flat, region.flat_to_global(Location { pos: pos_flat, rot: Mat2::IDENTITY }).pos, pos_global); assert_eq_at!(pos_flat, region.global_to_flat(pos_global), pos_flat); + assert_eq_at!(pos_global, region.global_to_flat(region.flat_to_global(Location { pos: pos_global, rot: Mat2::IDENTITY })).rot, Mat2::IDENTITY); } } }