forked from CoCoViLa/geometry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTriangle.java
48 lines (39 loc) · 1.14 KB
/
RTriangle.java
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
class RTriangle {
/*@ specification RTriangle {
double a, b, c, h, S, p, alpha, beta, gamma;
const double gamma = Math.PI/2;
a, alpha, gamma -> c {sinCalcSide};
a, beta -> c {cosCalcHyp};
b, alpha -> c {cosCalcHyp};
c, alpha -> a {cosCalcSide};
c, beta -> b {cosCalcSide};
b, beta, gamma -> c{sinCalcSide};
c, gamma, alpha -> a{sinCalcSide};
c, gamma, beta -> b{sinCalcSide};
a, c -> alpha {calcAngle};
b, c -> alpha {calcaCos};
a, c -> beta {calcaCos};
b, c -> beta {calcAngle};
c = (a^2 + b^2)^ (0.5);
S = a*b/2;
p = a + b + c;
}@*/
double calcAngle(double a, double c){
return Math.asin(a/c);
}
double calcSide(double a, double b){
return Math.sqrt(a*a - b*b);
}
double sinCalcSide(double a, double alpha, double beta)
{
return a/Math.sin(alpha)*Math.sin(beta);
}
double cosCalcHyp(double a, double alpha)
{
return a/Math.cos(alpha);
}
double cosCalcSide(double a, double alpha)
{
return a * Math.cos(alpha);
}
}