Rotate vectors about two axes.
npm install two-rotationsbower install two-rotations
In three dimensions, there are three possible rotations: one about each axis. In many visualizations, a combination of rotations about two of these axes is particularly important. This is because these visualizations allow users to rotate the object about two axes by dragging the mouse.
var vector = x y z;
In math lingo, this can be thought of as a column vector with dimensions
A point of confusion is that writing the array out like that makes it appear like a
vector. The actual relationship may be more clear when the vector is written out like so:
var vector =xyz;
// Define a vectorvar vector = 1 0 0;// Generate the rotation matrix from a `yaw` and `pitch`.var rotation = twoRotations;// Rotate a point with that matrixvar newVector = twoRotations;
generateMatrix( yaw, pitch )
Create a rotation matrix from a
pitch. Angles are measured in Radians.
rotate( vector, rotationMatrix )
matrix output from the
generateMatrix method – though any 3-by-3 matrix will work.
This library is intended to be used with mouse events. As such, the axes are based off of the axes defined by the browser viewport. The axes associated with mouse coordinates are illustrated below.
The axes of this library extend from that definition, adding a
z-axis that points outward from the screen, toward you. This
is shown in the following diagram.
The above diagram also indicates the direction of rotations.