Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: toji/gl-matrix
base: 5b627b7436
...
head fork: toji/gl-matrix
compare: 043034ae22
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Showing with 48 additions and 0 deletions.
  1. +48 −0 gl-matrix.js
View
48 gl-matrix.js
@@ -1703,6 +1703,30 @@ quat4.normalize = function (quat, dest) {
};
/**
+ * Performs quaternion addition
+ *
+ * @param {quat4} quat First operand
+ * @param {quat4} quat2 Second operand
+ * @param {quat4} [dest] quat4 receiving operation result. If not specified result is written to quat
+ *
+ * @returns {quat4} dest if specified, quat otherwise
+ */
+quat4.add = function (quat, quat2, dest) {
+ if(!dest || quat === dest) {
+ quat[0] += quat2[0];
+ quat[1] += quat2[1];
+ quat[2] += quat2[2];
+ quat[3] += quat2[3];
+ return quat;
+ }
+ dest[0] = quat[0]+quat2[0];
+ dest[1] = quat[1]+quat2[1];
+ dest[2] = quat[2]+quat2[2];
+ dest[3] = quat[3]+quat2[3];
+ return dest;
+};
+
+/**
* Performs a quaternion multiplication
*
* @param {quat4} quat First operand
@@ -1755,6 +1779,30 @@ quat4.multiplyVec3 = function (quat, vec, dest) {
};
/**
+ * Multiplies the components of a quaternion by a scalar value
+ *
+ * @param {quat4} quat to scale
+ * @param {number} val Value to scale by
+ * @param {quat4} [dest] quat4 receiving operation result. If not specified result is written to quat
+ *
+ * @returns {quat4} dest if specified, quat otherwise
+ */
+quat4.scale = function (quat, val, dest) {
+ if(!dest || quat === dest) {
+ quat[0] *= val;
+ quat[1] *= val;
+ quat[2] *= val;
+ quat[3] *= val;
+ return quat;
+ }
+ dest[0] = quat[0]*val;
+ dest[1] = quat[1]*val;
+ dest[2] = quat[2]*val;
+ dest[3] = quat[3]*val;
+ return dest;
+};
+
+/**
* Calculates a 3x3 matrix from the given quat4
*
* @param {quat4} quat quat4 to create matrix from

No commit comments for this range

Something went wrong with that request. Please try again.