-
Notifications
You must be signed in to change notification settings - Fork 1
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
mr::Quat implementation #19
Conversation
include/mr-math/quat.hpp
Outdated
} | ||
|
||
friend constexpr Vec<T, 3> operator*(const Vec<T, 3> &lhs, const Quat &rhs) noexcept { | ||
auto vq = rhs._vec * std::cos(rhs._angle._data / 2); |
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'd use const VecT
for clarity
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.
As we introduce more and more metaprogramming magic, we might cause implicit casts from Proxy classes to Underlying types, which is costly. I'd use auto where possible.
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.
fair enough
Consider adding |
Add explicit to Vec cast operator. Fix operator+-*.
@@ -55,8 +73,8 @@ namespace mr { | |||
|
|||
friend constexpr Quat operator*(const Quat &lhs, const Quat &rhs) noexcept { | |||
return { | |||
lhs[0] * rhs[0] - lhs & rhs, | |||
lhs._angle * rhs + rhs._angle * lhs + lhs % rhs | |||
mr::Radiansf(lhs.w() * rhs.w() - lhs.vec().dot(rhs.vec())), |
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.
We can return Radians
from w()
(and call it angle()
then), so such casts won't be necessary. That is also better, since user will be sure they dealing with radians
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.
Wouldn't you have to cast dot product to Radians or lhs.w() to T in this case?
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.
Ideally, Radians
would support arithmetic operations with primitive types. Since the conversion from Degrees
is explicit (I hope) that wouldn't lead to an ambiguity
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.
Actually, Radians
support + or - with Radians
and * or / with numbers (which makes sense). Then yep, we need to add the cast to the dot product
Benchmarks to be added