Allow using Decomp2 like a matrix
This commit is contained in:
parent
529d4ac7db
commit
88da1aa582
|
|
@ -153,8 +153,8 @@ fn rel_to_abs(space: &impl Metric, base: &Location, rel: Vec2, steps: usize) ->
|
|||
|
||||
/// Converts a position and a rotation to a [Location]. Only the X direction is preserved from `rot` to ensure the resulting Location describes an orthonormal coordinate system.
|
||||
fn put_object(space: &impl Metric, pos: Vec2, rot: Mat2) -> Location {
|
||||
let metric_sqrt = Mat2::from(space.sqrt_at(pos));
|
||||
let metric_inv_sqrt = Mat2::from(space.sqrt_at(pos).inverse());
|
||||
let metric_sqrt = space.sqrt_at(pos);
|
||||
let metric_inv_sqrt = space.sqrt_at(pos).inverse();
|
||||
let rot = metric_inv_sqrt * (metric_sqrt * rot).orthonormalize();
|
||||
Location { pos, rot }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,17 @@ impl Decomp2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::Mul<T> for Decomp2
|
||||
where
|
||||
Mat2: std::ops::Mul<T>,
|
||||
{
|
||||
type Output = <Mat2 as std::ops::Mul<T>>::Output;
|
||||
|
||||
fn mul(self, rhs: T) -> Self::Output {
|
||||
Mat2::from(self) * rhs
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Decomp2> for Mat2 {
|
||||
fn from(value: Decomp2) -> Self {
|
||||
value.ortho.transpose() * Mat2::from_diagonal(value.diag) * value.ortho
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user