Add hermite animation interpolation as an option#83
Add hermite animation interpolation as an option#83pragmatrix wants to merge 3 commits intomasterfrom
Conversation
…d start with a velocity of 3 like CubicOut
There was a problem hiding this comment.
Pull request overview
This PR adds Hermite interpolation as an animation option alongside the existing linear interpolation, enabling velocity-continuous animations that smoothly chain together. The implementation maintains backward compatibility by introducing an enum wrapper while preserving the existing linear interpolation as the default behavior.
Key Changes:
- Implements Hermite interpolation with velocity continuity for smoother animation chaining
- Refactors animation system to support multiple interpolation strategies via an enum pattern
- Adds
AddandMul<f64>trait implementations forTransformandPixelCameratypes
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| geometry/src/transform.rs | Implements Add and Mul<f64> traits for Transform to support hermite interpolation operations |
| geometry/src/pixel_camera.rs | Implements Add and Mul<f64> traits for PixelCamera to support hermite interpolation operations |
| applications/src/scene.rs | Updates animation method signature to require Add and Mul<f64> trait bounds |
| animation/src/lib.rs | Renames module from blended_animation to blended for improved organization |
| animation/src/blended/linear.rs | Renames BlendedAnimation struct to Linear as part of refactoring to support multiple interpolation types |
| animation/src/blended/hermite.rs | New file implementing Hermite interpolation with velocity continuity, including comprehensive tests |
| animation/src/blended.rs | New file introducing BlendedAnimation enum to dispatch between Linear and Hermite interpolation strategies |
| animation/src/animated.rs | Updates trait bounds to include Add and Mul<f64> requirements for hermite interpolation support |
| .github/copilot-instructions.md | Documents new coding guidelines learned from implementing this feature |
| fn add(self, rhs: Transform) -> Self::Output { | ||
| Transform { | ||
| translate: self.translate + rhs.translate, | ||
| rotate: self.rotate.slerp(rhs.rotate, 0.5), |
There was a problem hiding this comment.
The Add implementation for quaternion rotation uses slerp with a fixed 0.5 parameter, which averages the two rotations. This doesn't satisfy the mathematical properties of addition (e.g., commutativity and associativity with respect to the Hermite interpolation). For Hermite interpolation to work correctly with rotations, consider using quaternion addition or document why averaging is the intended behavior here.
| rotate: self.rotate.slerp(rhs.rotate, 0.5), | |
| rotate: self.rotate + rhs.rotate, |
No description provided.