forked from RobotWebTools/roslibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuaternion.js.html
132 lines (108 loc) · 4.14 KB
/
Quaternion.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: math/Quaternion.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: math/Quaternion.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* @author David Gossow - [email protected]
*/
/**
* A Quaternion.
*
* @constructor
* @param options - object with following keys:
* * x - the x value
* * y - the y value
* * z - the z value
* * w - the w value
*/
ROSLIB.Quaternion = function(options) {
options = options || {};
this.x = options.x || 0;
this.y = options.y || 0;
this.z = options.z || 0;
this.w = options.w || 1;
};
/**
* Perform a conjugation on this quaternion.
*/
ROSLIB.Quaternion.prototype.conjugate = function() {
this.x *= -1;
this.y *= -1;
this.z *= -1;
};
/**
* Perform a normalization on this quaternion.
*/
ROSLIB.Quaternion.prototype.normalize = function() {
var l = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
if (l === 0) {
this.x = 0;
this.y = 0;
this.z = 0;
this.w = 1;
} else {
l = 1 / l;
this.x = this.x * l;
this.y = this.y * l;
this.z = this.z * l;
this.w = this.w * l;
}
};
/**
* Convert this quaternion into its inverse.
*/
ROSLIB.Quaternion.prototype.invert = function() {
this.conjugate();
this.normalize();
};
/**
* Set the values of this quaternion to the product of itself and the given quaternion.
*
* @param q the quaternion to multiply with
*/
ROSLIB.Quaternion.prototype.multiply = function(q) {
var newX = this.x * q.w + this.y * q.z - this.z * q.y + this.w * q.x;
var newY = -this.x * q.z + this.y * q.w + this.z * q.x + this.w * q.y;
var newZ = this.x * q.y - this.y * q.x + this.z * q.w + this.w * q.z;
var newW = -this.x * q.x - this.y * q.y - this.z * q.z + this.w * q.w;
this.x = newX;
this.y = newY;
this.z = newZ;
this.w = newW;
};
/**
* Clone a copy of this quaternion.
*
* @returns the cloned quaternion
*/
ROSLIB.Quaternion.prototype.clone = function() {
return new ROSLIB.Quaternion(this);
};
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="ROSLIB.ActionClient.html">ActionClient</a></li><li><a href="ROSLIB.Goal.html">Goal</a></li><li><a href="ROSLIB.Message.html">Message</a></li><li><a href="ROSLIB.Param.html">Param</a></li><li><a href="ROSLIB.Pose.html">Pose</a></li><li><a href="ROSLIB.Quaternion.html">Quaternion</a></li><li><a href="ROSLIB.Ros.html">Ros</a></li><li><a href="ROSLIB.Service.html">Service</a></li><li><a href="ROSLIB.ServiceRequest.html">ServiceRequest</a></li><li><a href="ROSLIB.ServiceResponse.html">ServiceResponse</a></li><li><a href="ROSLIB.TFClient.html">TFClient</a></li><li><a href="ROSLIB.Topic.html">Topic</a></li><li><a href="ROSLIB.Transform.html">Transform</a></li><li><a href="ROSLIB.UrdfBox.html">UrdfBox</a></li><li><a href="ROSLIB.UrdfColor.html">UrdfColor</a></li><li><a href="ROSLIB.UrdfCylinder.html">UrdfCylinder</a></li><li><a href="ROSLIB.UrdfLink.html">UrdfLink</a></li><li><a href="ROSLIB.UrdfMaterial.html">UrdfMaterial</a></li><li><a href="ROSLIB.UrdfMesh.html">UrdfMesh</a></li><li><a href="ROSLIB.UrdfModel.html">UrdfModel</a></li><li><a href="ROSLIB.UrdfSphere.html">UrdfSphere</a></li><li><a href="ROSLIB.UrdfVisual.html">UrdfVisual</a></li><li><a href="ROSLIB.Vector3.html">Vector3</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ROSLIB">ROSLIB</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Tue May 07 2013 12:08:51 GMT-0400 (EDT)
</footer>
<script> prettyPrint(); </script>
</body>
</html>