xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Question:XML3DRotation.setRotation #144

Closed Arsakes closed 8 years ago

Arsakes commented 9 years ago

The manual says that function XML3DRotation.setRotation does following thing.

Replaces the existing rotation with one computed from the two vectors passed as arguments.

How one should understand that? How the rotation is computed from those two vectors?

Also could you clarify how multiply function works on example - i'm getting some unexpected results with this. (That is the rotations are performed in different order that I get from text): Lets say i have following code:

camera.orientation =  rot0.multiply(rot1)

Which rotation affects the camera first?

csvurt commented 9 years ago

setRotation is usually called fromTo in other math libraries. It computes the rotation needed to rotate the first vector to be parallel to the second vector. This is useful if you have a camera looking in direction a and want to rotate it to look in direction b for example.

In your example rot0 will be multiplied with rot1 and then the camera's orientation will be set to the result of that multiplication (which will be a new XML3DRotation object). The multiplication order is the same as the text order, so rot0 * rot1.