1#ifndef LEVELZ_COORDINATE_H
2#define LEVELZ_COORDINATE_H
43 return sqrt(pow(a->
x - b->
x, 2) + pow(a->
y - b->
y, 2));
52 return sqrt(pow(a->
x, 2) + pow(a->
y, 2));
62 return createCoordinate2D(a->
x + b->
x, a->
y + b->
y);
72 return createCoordinate2D(a->
x - b->
x, a->
y - b->
y);
81 char* str = (
char*) malloc(20);
82 sprintf(str,
"[%g, %g]", c->
x, c->
y);
92 char* str0 = (
char*) malloc(strlen(str) + 1);
95 char* x0 = strtok(str0,
"[], \t");
98 char* y0 = strtok(0,
"[], \t");
102 return createCoordinate2D(x, y);
132Coordinate3D* createCoordinate3D(
double x,
double y,
double z) {
147 return sqrt(pow(a->
x - b->
x, 2) + pow(a->
y - b->
y, 2) + pow(a->
z - b->
z, 2));
156 return sqrt(pow(a->
x, 2) + pow(a->
y, 2) + pow(a->
z, 2));
166 return createCoordinate3D(a->
x + b->
x, a->
y + b->
y, a->
z + b->
z);
176 return createCoordinate3D(a->
x - b->
x, a->
y - b->
y, a->
z - b->
z);
185 char* str = (
char*) malloc(20);
186 sprintf(str,
"[%g, %g, %g]", c->
x, c->
y, c->
z);
196 char* str0 = (
char*) malloc(strlen(str));
199 char* x0 = strtok(str0,
"[], \t");
202 char* y0 = strtok(0,
"[], \t");
205 char* z0 = strtok(0,
"[], \t");
209 return createCoordinate3D(x, y, z);
Definition coordinate.h:11
double y
Definition coordinate.h:20
double x
Definition coordinate.h:15
Definition coordinate.h:108
double x
Definition coordinate.h:112
double z
Definition coordinate.h:122
double y
Definition coordinate.h:117