28 v[0] = v[1] = v[2] = -1;
34 inline void conv(
double * i)
36 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
48 inline void conv(
float * i)
50 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
52 inline void conv(
double * i)
54 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
68 i[0] = (int) v[0]; i[1] = (int) v[1]; i[2] = (int) v[2];
70 inline void conv(
float * i)
72 i[0] =
static_cast<float>(v[0]); i[1] =
static_cast<float>(v[1]); i[2] =
static_cast<float>(v[2]);
74 inline void conv(
double * i)
76 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
85 sqr((p1[0] - p2[0]) * spacing[0])
86 +
sqr((p1[1] - p2[1]) * spacing[1])
87 +
sqr((p1[2] - p2[2]) * spacing[2])
96 norm[0] = v1[1] * v2[2] - v1[2] * v2[1];
97 norm[1] = v1[2] * v2[0] - v1[0] * v2[2];
98 norm[2] = v1[0] * v2[1] - v1[1] * v2[0];
100 absval = sqrt(norm[0] * norm[0] + norm[1] * norm[1] + norm[2] * norm[2]);
110 double prod = 0, length1 = 0, length2 = 0;
112 for(
int k = 0; k < 3; k++ )
114 prod += v1[k] * v2[k];
115 length1 += v1[k] * v1[k];
116 length2 += v2[k] * v2[k];
118 return acos(prod / sqrt(length1 * length2) );
125 double prod = 0, length1 = 0, length2 = 0;
127 for(
int k = 0; k < 3; k++ )
129 prod += v1[k] * v2[k];
130 length1 += v1[k] * v1[k];
131 length2 += v2[k] * v2[k];
133 return acos(prod / sqrt(length1 * length2) );
138 return sqrt(
sqr(x[0]) +
sqr(x[1]) +
sqr(x[2]) );
143 return sqrt(
sqr(x[0]) +
sqr(x[1]) +
sqr(x[2]) );
148 return sqrt(
sqr(x[0] - y[0]) +
sqr(x[1] - y[1]) +
sqr(x[2] - y[2]) );
153 double *origin,
int *dims,
double voxelsize)
157 for(
int i = 0; i < 3; i++ )
159 loc_img[i] = (int) ( (loc_world[i] - origin[i]) / voxelsize);
162 adjust = 1; loc_img[i] = 0;
164 if( loc_img[i] >= dims[i] )
166 loc_img[i] = dims[i] - 1; adjust = 1;
174 double *origin,
int *dims,
double voxelsize)
179 for(
int i = 0; i < 3; i++ )
181 loc_img[i] = (int) ( (loc_world[i] - origin[i]) / voxelsize);
184 adjust = 1; loc_img[i] = 0;
186 if( loc_img[i] >= dims[i] )
188 loc_img[i] = dims[i] - 1; adjust = 1;
double pointdistance(Coord3i &p1, Coord3i &p2, const double spacing[3])
double vectorangle(double *v1, double *v2)
double vec_length(Coord3d x)
double & operator[](int i)
void normcrossprod(double *v1, double *v2, double *norm)
int transWorldToImage(Coord3d loc_world, int *loc_img, double *origin, int *dims, double voxelsize)
float & operator[](int i)