dmc/
util.rs

1use cgmath::{Point3, Vector3};
2
3pub trait Interpolatable {
4    fn interpolate(self, other: Self, factor: f32) -> Self;
5}
6
7impl Interpolatable for Point3<f32> {
8    fn interpolate(self, other: Self, factor: f32) -> Self {
9        let diff = other - self;
10        self + diff * factor
11    }
12}
13
14impl Interpolatable for Vector3<f32> {
15    fn interpolate(self, other: Self, factor: f32) -> Self {
16        let diff = other - self;
17        self + diff * factor
18    }
19}