A three dimensional point.
More...
Go to the source code of this file.
A three dimensional point.
- Author
- Riku Klén
Definition in file point.c.
◆ getAngle()
Calculates xy-projection of angle FCX in degrees, where F=first point, C=centre point and X=point with higher x coordinate (y and z coordinate remain the same).
This is used to calculate polar angle with two dimensional points (z=constant).
- Returns
- Angle first - centre - x in degrees (0-360) and -360.0 if first point is equal to centre point.
- See also
- getDistance
- Parameters
-
| begin | First point. |
| center | Centre point. |
Definition at line 55 of file point.c.
60 {
61 float dx, dy;
62 dx = begin.
x - center.
x;
63 dy = begin.
y - center.
y;
64
65
66 if(dx == 0.0){
67 if(dy == 0.0) return -360.0;
68 if(dy > 0.0) return 90.0;
69 else return 270.0;
70 }
71 if(dy==0.0){
72 if(dx > 0.0) return 0.0;
73 else return 180.0;
74 }
75
76
77
78 if(dx<0.0) return 180.0 + atan(dy/dx)*180.0/M_PI;
79
80
81 if(dy>0.0) return atan(dy/dx)*180.0/M_PI;
82
83
84 return 360.0 + atan(dy/dx)*180.0/M_PI;
85}
◆ getDistance()
Calculate distance between points
- See also
- getAngle
- Returns
- Distance.
- Parameters
-
| begin | First point |
| end | Second point |
Definition at line 31 of file point.c.
36 {
37 float dx, dy, dz;
38
42 return sqrt(dx*dx + dy*dy + dz*dz);
43}
◆ pRound()
| int pRound |
( |
float | number | ) |
|
Round float to int.
- Returns
- Rounded value.
- Parameters
-
Definition at line 15 of file point.c.
18 {
19 if(number - floor(number) < 0.5){
20 return floor(number);
21 }
22 return ceil(number);
23}