Request: methods for fractional add of vector and fractional application of quaternion
See original GitHub issueRelated to (but not the same as) slerp, I need a method for scaling just the angle of a quaternion by a given factor, allowing for a single (non-slerp) quaternion to be applied to a given fractional amount. The code I have to do this is:
private static Quaterniond scaleQuatRotation(Quaterniond quat, double frac) {
AxisAngle4d axisAngle = new AxisAngle4d(quat);
double angle = axisAngle.angle;
if (angle > Math.PI) {
angle -= 2.0 * Math.PI;
}
return new Quaterniond(new AxisAngle4d(angle * frac, axisAngle.x, axisAngle.y, axisAngle.z));
}
However it would be more efficient to compute this internally to JOML, supplying a “fractional multiplication” method that scales the angle of a second quaternion when multiplying by a first quaternion, e.g.
prevRotation.mul(newRotation, frac, new Quaterniond())
Similarly I need a method that adds a fractionally scaled vector:
private static Vector3d addScaledVector(Vector3d vec1,Vector3d vec2, double frac) {
return vec1.add(vec2.mul(frac, new Vector3d()), new Vector3d());
}
but it would be more efficient to compute this internally to JOML using an API like
prevVec.add(newVec, frac, new Vector3d())
These methods are important for a range of interpolation tasks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
A quaternionic fractional Borel-Pompeiu type formula - arXiv
An introduction to fractional derivatives, fractional differential equations, to methods of their solution and some of their applications.
Read more >Understanding Quaternions | 3D Game Engine Programming
Quaternions are used to represent an orientation in 3D space. This article attempts to demystify the complexities of quaternions.
Read more >Quaternion algebras - Dartmouth College Mathematics
The book of Maclachlan–Reid [MR2003] gives an introduction to quaternion algebras with application to the geometry of 3-manifolds.
Read more >An Introduction to Hyperholomorphic Spectral Theories and ...
In the last section of this paper we explain how to treat fractional diffusion problems using the quaternionic spectral theory on the S-spectrum ......
Read more >(PDF) Fractional powers of higher order vector operators on ...
Using the $H^\infty$-functional calculus for quaternionic operators, we show how to generate the fractional powers of some densely defined ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am not sure that approximating sqrt is worth it. Assuming that the JIT lowers a
(float) sqrt()
to an x86SQRTSS
instruction, then this (on Skylake) has the same operation latency asDIVSS
(which would be needed for the approximation itself). In addition, we also need the comparison (which branch prediction can probably predict well when normalizing often).Latency tables: https://www.agner.org/optimize/instruction_tables.pdf
Thanks for the pointer. I see that
sqrt
is not yet approximated, and there is no entry in theMath
class for inversesqrt
. The inversesqrt
trick I linked above is very useful for quaternions when you normalize after every operation, since it is highly optimal when the magnitude of the result is already close to 1.0.