65 if (strcmp(units,
"meters") == 0) {
69 if (strcmp(units,
"miles") == 0) {
70 return (meters * .0006213712);
73 if (strcmp(units,
"kilometers") == 0) {
74 return (meters * .001);
77 if (strcmp(units,
"feet") == 0) {
78 return (meters * 3.280840);
81 if (strcmp(units,
"yards") == 0) {
82 return (meters * 1.093613);
85 if (strcmp(units,
"rods") == 0) {
86 return (meters * .1988388);
89 if (strcmp(units,
"inches") == 0) {
90 return (meters * 39.37008);
93 if (strcmp(units,
"centimeters") == 0) {
94 return (meters * 100.0);
97 if (strcmp(units,
"millimeters") == 0) {
98 return (meters * 1000.0);
101 if (strcmp(units,
"micron") == 0) {
102 return (meters * 1000000.0);
105 if (strcmp(units,
"nanometers") == 0) {
106 return (meters * 1000000000.0);
109 if (strcmp(units,
"cubits") == 0) {
110 return (meters * 2.187227);
113 if (strcmp(units,
"hands") == 0) {
114 return (meters * 9.842520);
117 if (strcmp(units,
"furlongs") == 0) {
118 return (meters * .004970970);
121 if (strcmp(units,
"nmiles") == 0) {
123 return (meters * .0005399568);
126 if (strcmp(units,
"chains") == 0) {
127 return (meters * .0497097);
149 return (
float)sqrt(
x *
x + y * y + z * z);
167 return (
float)sqrt(
x *
x + y * y);
250 n = sqrt(v1[
X] * v1[
X] + v1[
Y] * v1[
Y] + v1[
Z] * v1[
Z]);
275 n = sqrt(v1[
X] * v1[
X] + v1[
Y] * v1[
Y]);
299 n = sqrt(dv1[
X] * dv1[
X] + dv1[
Y] * dv1[
Y] + dv1[
Z] * dv1[
Z]);
328 n = sqrt(dx * dx + dy * dy + dz * dz);
334 v2[
X] = v1[
X] + dx / n;
335 v2[
Y] = v1[
Y] + dy / n;
336 v2[
Z] = v1[
Z] + dz / n;
358 n = sqrt(dx * dx + dy * dy + dz * dz);
361 v3[
X] = v3[
Y] = v3[
Z] = 0.0;
388 n = sqrt(dx * dx + dy * dy);
405 v3[
X] = (v1[
Y] * v2[
Z]) - (v1[
Z] * v2[
Y]);
406 v3[
Y] = (v1[
Z] * v2[
X]) - (v1[
X] * v2[
Z]);
407 v3[
Z] = (v1[
X] * v2[
Y]) - (v1[
Y] * v2[
X]);
420 *mag = sqrt(v1[
X] * v1[
X] + v1[
Y] * v1[
Y] + v1[
Z] * v1[
Z]);
442 static float *entrys =
NULL;
452 entrys = (
float *)
G_malloc(4 * nhist *
sizeof(
float));
465 for (i = 0; i < next; i += 4) {
466 if (entrys[i] == p1[0] && entrys[i + 1] == p1[1] &&
467 entrys[i + 2] == p2[0] && entrys[i + 3] == p2[1]) {
472 if (len == next / 4) {
476 entrys[next] = p1[0];
477 entrys[next + 1] = p1[1];
478 entrys[next + 2] = p2[0];
479 entrys[next + 3] = p2[1];
void G_free(void *)
Free allocated memory.
double Gs_distance(double *, double *)
Calculates distance in METERS between two points in current projection (2D)
void GS_v2dir(float *v1, float *v2, float *v3)
Get a normalized direction from v1 to v2, store in v3 (2D)
void GS_v3sub(float *v1, float *v2)
Subtract vectors.
void GS_v3mult(float *v1, float k)
Multiple vectors.
void GS_v3mag(float *v1, float *mag)
Magnitude of vector.
int GS_dv3norm(double *dv1)
Changes v1 so that it is a unit vector.
int GS_coordpair_repeats(float *p1, float *p2, int nhist)
ADD.
float GS_distance(float *from, float *to)
Calculate distance.
int GS_v2norm(float *v1)
Change v1 so that it is a unit vector (3D)
void GS_v3add(float *v1, float *v2)
Sum vectors.
int GS_v3norm(float *v1)
Change v1 so that it is a unit vector (2D)
void GS_v3eq(float *v1, float *v2)
Copy vector values.
double GS_geodistance(double *from, double *to, const char *units)
Calculate distance between 2 coordinates.
float GS_P2distance(float *from, float *to)
Calculate distance in plane.
int GS_v3dir(float *v1, float *v2, float *v3)
Get a normalized direction from v1 to v2, store in v3.
int GS_v3normalize(float *v1, float *v2)
Change v2 so that v1v2 is a unit vector.
void GS_v3cross(float *v1, float *v2, float *v3)
Get the cross product v3 = v1 cross v2.