GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
rotate.c
Go to the documentation of this file.
1
15
#include <math.h>
16
17
# define RpD ((2 * M_PI) / 360.)
/* radians/degree */
18
# define D2R(d) (double)(d * RpD)
/* degrees->radians */
19
# define R2D(d) (double)(d / RpD)
/* radians->degrees */
20
21
22
35
void
G_rotate_around_point
(
double
X0,
double
Y0,
double
*X1,
double
*Y1,
36
double
angle)
37
{
38
double
dx = *X1 - X0;
39
double
dy = *Y1 - Y0;
40
double
c = cos(
D2R
(angle));
41
double
s
= sin(
D2R
(angle));
42
double
dx1 = dx * c - dy *
s
;
43
double
dy1 = dx * s + dy * c;
44
45
*X1 = X0 + dx1;
46
*Y1 = Y0 + dy1;
47
}
48
62
void
G_rotate_around_point_int
(
int
X0,
int
Y0,
int
*X1,
int
*Y1,
double
angle)
63
{
64
double
x = (double)*X1;
65
double
y = (double)*Y1;
66
67
if
(angle == 0.0)
68
return
;
69
70
G_rotate_around_point
((
double
)X0, (
double
)Y0, &x, &y, angle);
71
72
*X1 = (int)floor(x + 0.5);
73
*Y1 = (int)floor(y + 0.5);
74
}
lib
gis
rotate.c
Generated on Sun Sep 9 2012 18:55:34 for GRASS Programmer's Manual by
1.8.1.2