diff --git a/crates/fj-math/src/transform.rs b/crates/fj-math/src/transform.rs index b25be9c9a..2fbd7a6eb 100644 --- a/crates/fj-math/src/transform.rs +++ b/crates/fj-math/src/transform.rs @@ -53,6 +53,12 @@ impl Transform { Vector::from([d[0], d[1], d[2]]) } + /// # Extract the "up" vector from the rotational component + pub fn up(&self) -> Vector<3> { + let d = self.data(); + Vector::from([d[4], d[5], d[6]]) + } + /// Transform the given point pub fn transform_point(&self, point: &Point<3>) -> Point<3> { Point::from(self.0.transform_point(&point.to_na())) diff --git a/crates/fj-viewer/src/input/rotation.rs b/crates/fj-viewer/src/input/rotation.rs index 6263c3312..4a76fb22f 100644 --- a/crates/fj-viewer/src/input/rotation.rs +++ b/crates/fj-viewer/src/input/rotation.rs @@ -1,4 +1,4 @@ -use fj_math::{Transform, Vector}; +use fj_math::Transform; use crate::camera::{Camera, FocusPoint}; @@ -15,7 +15,7 @@ impl Rotation { // the model rotates not the camera, so invert the transform let camera_rotation = camera.rotation.inverse(); - let up_vector = up_vector(&camera_rotation); + let up_vector = camera_rotation.up(); let rotation = Transform::rotation(camera_rotation.right() * angle_x) * Transform::rotation(up_vector * angle_y); @@ -29,8 +29,3 @@ impl Rotation { camera.translation = transform.extract_translation(); } } - -fn up_vector(rotation: &Transform) -> Vector<3> { - let d = rotation.data(); - Vector::from([d[4], d[5], d[6]]) -}