Skip to content

Commit

Permalink
Add Plane::translate
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Dec 17, 2024
1 parent 50d5703 commit 9985efa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 8 additions & 1 deletion experiments/2024-12-09/src/math/plane.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{Bivector, Point};
use super::{Bivector, Point, Vector};

#[derive(Clone, Copy)]
pub struct Plane {
Expand All @@ -11,4 +11,11 @@ impl Plane {
let [u, v] = point.into().coords.components;
self.origin + self.coords.a * u + self.coords.b * v
}

pub fn translate(self, offset: impl Into<Vector<3>>) -> Self {
Self {
origin: self.origin + offset,
coords: self.coords,
}
}
}
8 changes: 1 addition & 7 deletions experiments/2024-12-09/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ pub fn model(shape: &mut Shape) {
b: Vector::from([0., 1., 0.]),
},
};
let top = Plane {
origin: Point::from([0., 0., 0.5]),
coords: Bivector {
a: Vector::from([1., 0., 0.]),
b: Vector::from([0., 1., 0.]),
},
};
let top = bottom.translate([0., 0., 1.]);

let (a, b, c, d, e, f, g, h) = shape
.extend_with(&mut vertices)
Expand Down

0 comments on commit 9985efa

Please sign in to comment.