This commit is contained in:
numzero 2024-06-30 12:13:57 +03:00
parent dff3f94f68
commit b58dcbd4a9

View File

@ -230,9 +230,10 @@ mod coords {
impl FlatCoordinateSystem<Location> 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<Location> 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);
}
}
}