-
Notifications
You must be signed in to change notification settings - Fork 447
/
math.html
64 lines (46 loc) · 1.28 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Math - Leap</title>
<script src="../leap-1.1.1.js"></script>
<script>
Leap.loop({
frame: function(frame){
var hand = frame.hands[0];
if (hand){
var dot = Leap.vec3.dot(hand.direction, hand.indexFinger.direction);
console.assert(!isNaN(dot));
out.innerHTML = dot.toPrecision(2);
}
}
});
</script>
<style>
body {
line-height: 2em;
font-family: Helvetica;
}
#out{
font-weight: bold;
}
</style>
</head>
<body>
<p>
This page demonstrates the usage of basic vector Math with the Leap. In this example, we will compute the dot-product,
of hand direction and index finger direction. This is a measure of how close two vectors are.
</p>
<p>
Find out more in the <a target="_blank" href="http://glmatrix.net/docs/2.2.0/">GL-Matrix Documentation</a> and
<a href="http://en.wikipedia.org/wiki/Dot_product" target="_blank">Wikipedia</a>.
</p>
<p>
<img src="images/dot-product.png"/>
</p>
<br/>
<p>
hand.direction · hand.indexFinger.direction =
<span id="out"></span>
</p>
</body>
</html>