-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatjava.html
50 lines (43 loc) · 993 Bytes
/
matjava.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
<html>
<head> </head>
<body>
<script>
var x1 = 0;
var y1 = 0;
var x2 = 2 * Math.sqrt(3);
var y2 = 2;
var x3 = 0;
var y3 = 2;
var x_1 = x2 - x1;
var y_1 = y2 - y1;
var x_2 = x3 - x2;
var y_2 = y3 - y2;
var l1 = Math.sqrt(x_1 * x_1 + y_1 * y_1);
var l2 = Math.sqrt(x_2 * x_2 + y_2 * y_2);
var k1 = y_1 / x_1;
var k2 = y_2 / x_2;
function angle(k) {
if (k === Infinity) {
return 90;
} else if (k === -Infinity) {
return 270;
} else {
return (Math.atan(k) * 180) / Math.PI;
}
}
if (angle(k1) === angle(k2)) {
kut = 0;
} else if (angle(k1) > angle(k2)) {
kut = angle(k1) - angle(k2);
} else {
kut = angle(k2) - angle(k1);
}
if (kut > 180) {
kut -= 360;
}
console.log(l1);
console.log(l2);
console.log(kut);
</script>
</body>
</html>