Tag Info

Hot answers tagged

4

To get a value inside [-pi,pi], you can add pi, do fmod, and subtract pi again. Here is one way that works. Unfortunately you still need to somehow test whether from - to is positive or negative before calling fmod: Scalar rotationBetween(Scalar from, Scalar to) { return (from > to) ? -pi + std::fmod(from - to + pi, pi * 2) : ...


4

All 3D rotation must occur about some axis. That's what 3D rotation is. However, not all such rotation occurs about the Z axis. Rotation can be about any axis: X, Y, Z or an arbitrary axis not aligned with any of the principle axes of the coordinate system. What it sounds like you're referring to is the convention of rotating 2D shapes in a 2D plane about ...


1

I don't know if this is a typo in your question or the actual mistake: x = normalize(Oa); v = normalize(Ob); z = a.crossProduct(b); y = x.crossProduct(z); For one you don't seem to be using v at all, but your z looks wrong to me. Did you mean the following? z = normalize(Oa.crossProduct(Ob)); Note the Oa and Ob instead of a and b. The difference is the ...


1

You could do something as simple as XMVector3TransformNormal of the direction light with the original Rotation. Generally in SIMD-friendly coding, individual component access is a performance hit, so you want to avoid doing it whenever possible. That's why in DirectXMath (aka XNAMath version 3) the individual element members _11 - _44 were removed from ...



Only top voted, non community-wiki answers of a minimum length are eligible