TPCCLIB
Loading...
Searching...
No Matches
point.c
Go to the documentation of this file.
1
5/***********************************************************************/
6
7/***********************************************************************/
8#include "libtpcimgp.h"
9/***********************************************************************/
10
11/***********************************************************************/
17 float number
18) {
19 if(number - floor(number) < 0.5){
20 return floor(number);
21 }
22 return ceil(number);
23}
24/***********************************************************************/
25
26/***********************************************************************/
33 point begin,
35 point end
36) {
37 float dx, dy, dz;
38
39 dx = begin.x - end.x; // Difference in x coordinates.
40 dy = begin.y - end.y; // Difference in y coordinates.
41 dz = begin.z - end.z; // Difference in z coordinates.
42 return sqrt(dx*dx + dy*dy + dz*dz);
43}
44/***********************************************************************/
45
46/***********************************************************************/
57 point begin,
59 point center
60) {
61 float dx, dy;
62 dx = begin.x - center.x; // Difference in x coordinates.
63 dy = begin.y - center.y; // Difference in y coordinates.
64
65 // Check trivial cases.
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 // If it was not a trivial case, then calculate angle in...
77 // ...the second and the third quarter.
78 if(dx<0.0) return 180.0 + atan(dy/dx)*180.0/M_PI;
79
80 // ...the first quarter.
81 if(dy>0.0) return atan(dy/dx)*180.0/M_PI;
82
83 // ...the fourth quarter.
84 return 360.0 + atan(dy/dx)*180.0/M_PI;
85}
86/***********************************************************************/
87
88/***********************************************************************/
Header file for libtpcimgp.
float getAngle(point begin, point center)
Definition point.c:55
float getDistance(point begin, point end)
Definition point.c:31
int pRound(float number)
Definition point.c:15
float z
Definition libtpcimgp.h:47
float y
Definition libtpcimgp.h:45
float x
Definition libtpcimgp.h:43