[Bf-committers] arithb.c QuatToMat3 question
Arne Schmitz
arne.schmitz at gmx.net
Sun Sep 17 07:40:34 CEST 2006
Am Sonntag, 17. September 2006 07:36 schrieb Tom M:
> In QuatToMat3 and QuatToMat4
>
> we see q0= M_SQRT2 * q[0];
> q1= M_SQRT2 * q[1];
> q2= M_SQRT2 * q[2];
> q3= M_SQRT2 * q[3];
>
> this appears to be done to later save multiplications by two in the
> following
>
> qda= q0*q1;
> qdb= q0*q2;
> qdc= q0*q3;
> qaa= q1*q1;
> qab= q1*q2;
> qac= q1*q3;
> qbb= q2*q2;
> qbc= q2*q3;
> qcc= q3*q3;
>
> however I would think that if we leave it as multiply by 2, then the
> compiler will recognize it as a bitshift, which I would think would
> end up ultimately faster.
Floats cannot be bit-shifted. Nevertheless is the above code not optimal,
since it is prone to rounding errors. Deleting the first four line and then
writing:
qda = 2.0f * q[0] * q[1];
...
should be more stable.
Cheers,
Arne
--
Dipl.-Inform. Arne Schmitz Phone +49 (0)241 80-21817
Computer Graphics Group Fax +49 (0)241 80-22899
RWTH Aachen University http://www.rwth-graphics.de
Ahornstrasse 55, 52074 Aachen, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://projects.blender.org/pipermail/bf-committers/attachments/20060917/26d339d7/attachment.pgp
More information about the Bf-committers
mailing list