0.2.0-dev Download ZIP
19 lines ·564 B Raw
| 1 | using System.Numerics; |
| 2 | |
| 3 | namespace EvilEngine.GenerativeMotion; |
| 4 | |
| 5 | public readonly record struct Rigid(Vector3 Position, Quaternion Rotation) |
| 6 | { |
| 7 | public static Rigid Identity => new(Vector3.Zero, Quaternion.Identity); |
| 8 | |
| 9 | public static Rigid operator *(Rigid a, Rigid b) |
| 10 | { |
| 11 | return new Rigid(WarpMath.Rotate(a.Rotation, b.Position) + a.Position, WarpMath.Mul(a.Rotation, b.Rotation)); |
| 12 | } |
| 13 | |
| 14 | public Rigid Inverse() |
| 15 | { |
| 16 | var inverse = WarpMath.Inverse(Rotation); |
| 17 | return new Rigid(-WarpMath.Rotate(inverse, Position), inverse); |
| 18 | } |
| 19 | } |