Gazi Alankus wrote:
I recently discovered a bug in my code that made me question the
choice of the operator chosen for vector cross product in osg.
The bitwise xor operator (^) has a lower precedence than addition
operator (+) in C++. So, addition is done before cross product, which
is not intuitive and is not the case in mathematics. I decided to stop
using the ^ operator for cross product, but I couldn't find a function
version for it - the operator looks like the only choice. I know I can
write one myself, but I just wanted to point this issue out since it
probably will lead to bugs in many other people's code.

My apologies if I'm missing something.

In C++, the ^ operator is nothing more than an overloaded operator^() that takes the right arguments. Therefore, instead of writing:

  a ^ b

You can write:

  operator^(a, b)

And since function calls have a very high precedence (and the comma operator has a very low precedence) this might achieve your goal.

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to