-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete the docs for Quaternion #84140
Conversation
doc/classes/Quaternion.xml
Outdated
@@ -79,6 +79,7 @@ | |||
<method name="exp" qualifiers="const"> | |||
<return type="Quaternion" /> | |||
<description> | |||
Returns the [url=https://en.wikipedia.org/wiki/Quaternion#Exponential,_logarithm,_and_power_functions]exponential[/url] of this quaternion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about linking to Wikipedia here, the link is not guaranteed to be preserved, and we don't do it for the other ones here, I'd suggest providing an explanation here instead, as the equations aren't very complicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially considering this is the code, which is trivial to explain:
Quaternion Quaternion::log() const {
Quaternion src = *this;
Vector3 src_v = src.get_axis() * src.get_angle();
return Quaternion(src_v.x, src_v.y, src_v.z, 0);
}
Quaternion Quaternion::exp() const {
Quaternion src = *this;
Vector3 src_v = Vector3(src.x, src.y, src.z);
real_t theta = src_v.length();
src_v = src_v.normalized();
if (theta < CMP_EPSILON || !src_v.is_normalized()) {
return Quaternion(0, 0, 0, 1);
}
return Quaternion(src_v, theta);
}
And at least I can't work out what the method is doing from the Wiki but the code is very clear
I thought it could be explained with a link since I saw it is done in Vector3. I changed the docs to explain the code better. |
The use of exponential and log of quaternion is that if you randomly pick a value it will be on the rotation sphere, which then you can use then extract into a quaternion rotation. Any quaternion that isn't on the rotation sphere is not a rotation. See the review of the three methods of rotation interpolation by Jonathan Blow: See also https://web.mit.edu/2.998/www/QuaternionReport1.pdf for an exhaustive textbook. |
Looks good! Could you squash the commits? See PR workflow for instructions. While doing so, please amend the resulting commit message to be more explicit (e.g. like the PR title). |
0b623a3
to
d67e7f8
Compare
Commits squashed! |
Thanks! |
Cherry-picked for 4.2.2. |
Added documentation for some methods in the Quaternion class where it was missing.