diff options
Diffstat (limited to 'src/geom/linear.rs')
| -rw-r--r-- | src/geom/linear.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/geom/linear.rs b/src/geom/linear.rs index 77923c43..78602d8b 100644 --- a/src/geom/linear.rs +++ b/src/geom/linear.rs @@ -36,6 +36,16 @@ impl Linear { self.rel.resolve(length) + self.abs } + /// Compose with another linear. + /// + /// The resulting linear is (self ∘ inner)(x) = self(inner(x)). + pub fn compose(self, inner: Self) -> Self { + Self { + rel: self.rel * inner.rel, + abs: self.rel.resolve(inner.abs) + self.abs, + } + } + /// Whether both parts are zero. pub fn is_zero(self) -> bool { self.rel.is_zero() && self.abs.is_zero() @@ -155,10 +165,7 @@ impl Mul<Linear> for f64 { type Output = Linear; fn mul(self, other: Linear) -> Linear { - Linear { - rel: self * other.rel, - abs: self * other.abs, - } + other * self } } |
