JavaScript semantic change

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: JavaScript semantic change

Post by Eric Walch »

Ahruman wrote:
I’m going through Quaternion’s properties to write unit tests, and wondered what the quaternion dot product was actually good for. It turns out that it’s a good measure of difference; similar normalized quaternions have a dot product near 1. For example, oldOrientation.dot(currentOrientation) > 0.999 will detect changes of more than about five degrees around any axis.
I didn't realise we had a dot product for quaternions. I did know it was useful to compare the alignment of two vectors. I just put the code in script and compared the dot product from two similar player orientations. It is either 1.0 or a number with at least the first 6 digits equal 1:

Code: Select all

dot product: 1.0000001192092896
dot product: 1
The last bit are rounding errors. > 0.999 seems close enough for practical checks. Better than comparing two vectors. Good vision when you added that code :wink:
Post Reply