aion
New Member
Posts: 1

Post by aion on May 29, 2022 8:07:58 GMT
Hello, On page 100, in the function view_transform(from, to, up), The left vector is calculated from cross(forward, upn), but this doesn't guarantee that the left vector is normalized.
I think the left vector should be normalized so that the left, true_up, and forward can form an orthonormal basis. Am I correct?
Thanks!



Post by Jamis on Jun 17, 2022 19:03:29 GMT
I don't believe that's explicitly necessary; I haven't proved it mathematically, but empirically, normalizing the forward and up vectors before crossing them results in a normalized result. Have you encountered a case where explicitly normalizing the left vector is necessary, even when the forward and up vectors have been normalized?


bb
New Member
Posts: 1

Post by bb on Aug 20, 2022 21:41:16 GMT
> empirically, normalizing the forward and up vectors before crossing them results in a normalized result. Sorry, but that is not correct. The cross product of two normalized vectors is only normalized if they are perpendicular. Actually: the length is the products of the individual lengths (in this case 1) times the sine of the angle between them. The sine is only 1 iff the vectors are perpendicular.
In general, 'forward' and 'up' are not perpendicular, as otherwise there would be no need for the corrected 'true_up'.
As aion pointed out, the three vectors need to span an orthonormal basis, so that the upper left 3x3 matrix is a rotation matrix.
I have read many other books on raytracing and they all make sure that the three vectors are perpendicular.
The correct way would thus be to normalize cross(forward,up). There is by the way no need to normalize 'up' at all.
> Have you encountered a case where explicitly normalizing the left vector is necessary, even when the forward and up vectors have been normalized? Take for instance forward=(0, 0, 1) and (normalized) up=(0, 0.6, 0.8), then left=cross(forward,up) = (0.6, 0, 0). This is clearly not normalized.

