42 inline void conv(
double * i)
44 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
56 inline void conv(
float * i)
58 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
60 inline void conv(
double * i)
62 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
76 i[0] = (int) v[0]; i[1] = (int) v[1]; i[2] = (int) v[2];
78 inline void conv(
float * i)
80 i[0] =
static_cast<float>(v[0]); i[1] =
static_cast<float>(v[1]); i[2] =
static_cast<float>(v[2]);
82 inline void conv(
double * i)
84 i[0] = v[0]; i[1] = v[1]; i[2] = v[2];
93 norm[0] = v1[1] * v2[2] - v1[2] * v2[1];
94 norm[1] = v1[2] * v2[0] - v1[0] * v2[2];
95 norm[2] = v1[0] * v2[1] - v1[1] * v2[0];
97 absval = sqrt(norm[0] * norm[0] + norm[1] * norm[1] + norm[2] * norm[2]);
107 double prod = 0, length1 = 0, length2 = 0;
109 for(
int k = 0; k < 3; k++ )
111 prod += v1[k] * v2[k];
112 length1 += v1[k] * v1[k];
113 length2 += v2[k] * v2[k];
115 return acos(prod / sqrt(length1 * length2) );
122 double prod = 0, length1 = 0, length2 = 0;
124 for(
int k = 0; k < 3; k++ )
126 prod += v1[k] * v2[k];
127 length1 += v1[k] * v1[k];
128 length2 += v2[k] * v2[k];
130 return acos(prod / sqrt(length1 * length2) );
135 return sqrt(
sqr(x[0]) +
sqr(x[1]) +
sqr(x[2]) );
140 return sqrt(
sqr(x[0]) +
sqr(x[1]) +
sqr(x[2]) );
145 return sqrt(
sqr(x[0] - y[0]) +
sqr(x[1] - y[1]) +
sqr(x[2] - y[2]) );
149 double *origin,
int *dims,
double voxelsize)
154 for(
int i = 0; i < 3; i++ )
156 loc_img[i] = (int) ( (loc_world[i] - origin[i]) / voxelsize);
159 adjust = 1; loc_img[i] = 0;
161 if( loc_img[i] >= dims[i] )
163 loc_img[i] = dims[i] - 1; adjust = 1;
171 double *origin,
int *dims,
double voxelsize)
176 for(
int i = 0; i < 3; i++ )
178 loc_img[i] = (int) ( (loc_world[i] - origin[i]) / voxelsize);
181 adjust = 1; loc_img[i] = 0;
183 if( loc_img[i] >= dims[i] )
185 loc_img[i] = dims[i] - 1; adjust = 1;
double vectorangle(double *v1, double *v2)
double vec_length(Coord3d x)
double & operator[](int i)
void normcrossprod(double *v1, double *v2, double *norm)
struct point_struct point
int transWorldToImage(Coord3d loc_world, int *loc_img, double *origin, int *dims, double voxelsize)
float & operator[](int i)