This commit is contained in:
2022-05-11 15:41:31 -05:00
parent 8300f2a254
commit 8c6f54054c
3 changed files with 28 additions and 29 deletions

View File

@@ -147,7 +147,7 @@ fn inv_lerp(v0: f32, v1: f32, a: f32) -> f32 {
pub trait CoordTransformer<I: Into<(f32, f32)> + From<(f32, f32)>> {
fn origin(&self) -> I;
fn extremes(&self) -> I;
fn to_coords(&self, pos: I) -> (f32, f32) {
fn xform(&self, pos: I) -> (f32, f32) {
let (sx, sy) = self.origin().into();
let (ex, ey) = self.extremes().into();
let (x, y) = pos.into();
@@ -156,7 +156,7 @@ pub trait CoordTransformer<I: Into<(f32, f32)> + From<(f32, f32)>> {
inv_lerp(sy, ey, y),
)
}
fn from_coords(&self, x: f32, y: f32) -> I {
fn inv_xform(&self, x: f32, y: f32) -> I {
let (sx, sy) = self.origin().into();
let (ex, ey) = self.extremes().into();
(lerp(sx, ex, x), lerp(sy, ey, y)).into()