Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Trackball rotation return quaternion or rotation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
LeleVic committed May 11, 2015
1 parent 384b3ae commit 301eb8e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions App/trackball.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Trackball(center, radius) {
* @param y2 y-axis final position
* @return Rotation quaternion to rotate vector in the trackball
*/
Trackball.prototype.rotation = function(x1, y1, x2, y2) {
Trackball.prototype.rotation = function(x1, y1, x2, y2, mORq) {
var z1 = this.calculateZ(x1, y1);
var z2 = this.calculateZ(x2, y2);

Expand All @@ -35,7 +35,10 @@ Trackball.prototype.rotation = function(x1, y1, x2, y2) {
var N = cross(V1, V2);
var theta = 10 * dot(V1, V2);

return createRotationQuaternionFromAngleAndAxis(theta, N);
if (mORq == 'q') // return a quaternion
return createRotationQuaternionFromAngleAndAxis(theta, N);
else // return a matrix
return rotate(theta, N);
}

/**
Expand Down

0 comments on commit 301eb8e

Please sign in to comment.