-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Do not use angleBetween() for angle calculation in _orbit() inside orbtiControl(). #6154
Do not use angleBetween() for angle calculation in _orbit() inside orbtiControl(). #6154
Conversation
Since angleBetween() can return negative numbers, modify it so that it only returns positive numbers. This function is not used because it is inconvenient to be affected by the specification change of angleBetween().
The idea of executing angleBetween() with abs cannot be adopted. |
@@ -1746,7 +1746,8 @@ p5.Camera.prototype._orbit = function(dTheta, dPhi, dRadius) { | |||
|
|||
// calculate updated camera angle | |||
// Find the angle between the "up" and the "front", add dPhi to that. | |||
const camPhi = front.angleBetween(up) + dPhi; | |||
const camPhi = |
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.
Makes sense, can we add a comment explaining what this does differently from angleBetween
for context for future readers?
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.
"Since the specifications of angleBetween() are subject to change due to version updates, a calculation method that directly obtains the angle between two vectors is used here."
How about this?
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.
Should I mention the possibility of getting negative numbers?
"angleBetween() can return negative numbers. Since this specification is subject to change due to version updates, it cannot be adopted, so here we calculate using a method that directly obtains the absolute value."
Is this better?
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 think mentioning negative numbers is good, since that's main motivation and the bit that would cause a bug (and using a separate implementation instead of abs() just makes it a bit more efficient and less likely to break in the future.) Your text looks good!
add explanation of not using angleBetween()
Perhaps it would be more reliable to enclose acos with abs, but it would be complicated and I don't think the javascript specification will change so much, so I think this is fine. |
Thanks so much! ('ω') |
Since angleBetween() can return negative numbers, modify it so that it only returns positive numbers.
This function is not used because it is inconvenient to be affected by the specification change of angleBetween().
Resolves #6153
Changes:
before:
after:
PR Checklist
npm run lint
passes