forked from RobotWebTools/roslibjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.html
52 lines (47 loc) · 1018 Bytes
/
math.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://static.robotwebtools.org/EventEmitter2/current/eventemitter2.min.js"></script>
<script src="../build/roslib.js"></script>
<script>
// Let's start by adding some vectors.
var v1 = new ROSLIB.Vector3({
x : 1,
y : 2,
z : 3
});
var v2 = v1.clone();
v1.add(v2);
console.log(v1);
// Now let's play with some quaternions.
var q1 = new ROSLIB.Quaternion({
x : 0.1,
y : 0.2,
z : 0.3,
w : 0.4
});
var q2 = q1.clone();
q1.multiply(q2);
q1.invert();
console.log(q1);
// Let's copy the results into a pose.
var p = new ROSLIB.Pose({
position : v1,
orientation : q1
});
console.log(p);
// Finally, let's play with some transforms.
var tf = new ROSLIB.Transform({
translation : v2,
rotation : q2
});
p.applyTransform(tf);
console.log(p);
</script>
</head>
<body>
<h1>Simple Math Example</h1>
<p>Check the JavaScript console for the output.</p>
</body>
</html>