question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add .pow(exponent) and .multiplyByExponentiatedQuaternion(quat2, exponent) methods to the Quaternion class

See original GitHub issue

Is your feature request related to a problem? Please describe.

Hello! I want to be able to handle rotations in my engine in similar way to the positions - I can write position.addScaledVector(velocity, timePassed) if I want to program moving with some velocity frame-by-frame and I want to be able to do similar thing for quaternions (or at least thing similar to position.add(velocity.clone().scale(timePassed))), i.e. rotation.multiplyByExponentiatedQuaternion(rotationalVelocity, timePassed) (or rotation.multiply(rotationalVelocity.clone().pow(timePassed))).

Describe the solution you’d like

I suggest that methods .pow(exponent) and .multiplyByExponentiatedQuaternion(quat2, exponent) would be added to the Quaternion class.

Describe alternatives you’ve considered

These methods could be added just by monkey-patching the prototype of the Quaternion class (and it is how I do it currently).

Additional context

The methods could be implemented similar to glMatrix’s pow(out, a, b) function: https://github.com/toji/gl-matrix/blob/master/src/quat.js#L280.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
WestLangleycommented, Dec 6, 2021

@Mugen87 Conceptually, quaternion.pow() is the same as

const _vec3 = new THREE.Vector3();
const _vec4 = new THREE.Vector4();

//

_vec4.setAxisAngleFromQuaternion( q );

q.setFromAxisAngle( _vec3.set( _vec4.x, _vec4.y, _vec4.z ), _vec4.w * alpha );

Add pow() if you want, if it can be made efficient. I would not support adding the other method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pyquaternion
A fully featured python module for quaternion representation, manipulation, 3D rotation and animation.
Read more >
Rotations, Orientation, and Quaternions - MATLAB & Simulink
This example reviews concepts in three-dimensional rotations and how quaternions are used to describe orientation and rotations.
Read more >
JSDoc: Module: quat - glMatrix
Calculate the exponential of a unit quaternion. Parameters: Name, Type, Description. out, quat, the receiving quaternion.
Read more >
Scripting API: Quaternion - Unity - Manual
Converts a rotation to angle-axis representation (angles in degrees). ToString, Returns a formatted string for this quaternion. Static Methods. Angle, Returns ...
Read more >
Algebras - SymPy 1.11 documentation
This section lists the classes implemented by the Algebras module. ... The resultant quaternion after adding self to other. Examples.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found