mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 09:58:27 +00:00
Add Transform::up
This commit is contained in:
parent
63448f4469
commit
a9debaccb3
@ -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()))
|
||||
|
@ -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]])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user