diff --git a/src/bin/flat/tube/mod.rs b/src/bin/flat/tube/mod.rs index 1681647..81f06a3 100644 --- a/src/bin/flat/tube/mod.rs +++ b/src/bin/flat/tube/mod.rs @@ -203,6 +203,23 @@ mod coords { fn global_metric(&self) -> &impl Metric; } + impl + MetricCS> FlatCoordinateSystem for T { + fn flat_to_global(&self, ray: Ray) -> Ray { + let pos = self.flat_to_global(ray.pos); + Ray { + pos, + dir: Mat2::from(self.global_metric().sqrt_at(pos).inverse()) * ray.dir, + } + } + + fn global_to_flat(&self, ray: Ray) -> Ray { + Ray { + pos: self.global_to_flat(ray.pos), + dir: Mat2::from(self.global_metric().sqrt_at(ray.pos)) * ray.dir, + } + } + } + impl + MetricCS> FlatCoordinateSystem for T { fn flat_to_global(&self, loc: Location) -> Location { let pos = self.flat_to_global(loc.pos); @@ -235,22 +252,6 @@ mod coords { } } - impl FlatCoordinateSystem for InnerCS { - fn flat_to_global(&self, ray: Ray) -> Ray { - Ray { - pos: self.flat_to_global(ray.pos), - dir: vec2(ray.dir.x, self.0.dy(ray.pos.y) * ray.dir.y), - } - } - - fn global_to_flat(&self, ray: Ray) -> Ray { - Ray { - pos: self.global_to_flat(ray.pos), - dir: vec2(ray.dir.x, self.0.dv(ray.pos.y) * ray.dir.y), - } - } - } - impl FlatRegion for InnerCS { fn distance_to_boundary(&self, ray: Ray) -> Option { Rect { size: vec2(self.0.inner_radius, self.0.internal_halflength) }.trace_out_of(ray) @@ -285,8 +286,6 @@ mod coords { } } - impl FlatCoordinateSystem for OuterCS {} - impl FlatRegion for OuterCS { fn distance_to_boundary(&self, ray: Ray) -> Option { Rect { size: vec2(self.0.outer_radius, self.0.external_halflength) }.trace_into(ray)