Go to the documentation of this file.
27 #ifndef __MINMAX_DEFINED
28 #define __MINMAX_DEFINED
44 return t1 > t2 ? t2 : t1;
50 return t1 > t2 ? t1 : t2;
65 return sqrt(pnt[ 0 ] * pnt[ 0 ] + pnt[ 1 ] * pnt[ 1 ]
66 + pnt[ 2 ] * pnt[ 2 ]);
92 dst[ 0 ] = dst[ 1 ] = dst[ 2 ] = 0;
96 printf(
"(%g, %g, %g)\n", pnt[ 0 ], pnt[ 1 ], pnt[ 2 ]);
103 return a[ 0 ] * b[ 0 ]
112 out[ 0 ] =
a[ 1 ] * b[ 2 ] -
a[ 2 ] * b[ 1 ];
113 out[ 1 ] = - (
a[ 0 ] * b[ 2 ] -
a[ 2 ] * b[ 0 ]);
114 out[ 2 ] =
a[ 0 ] * b[ 1 ] -
a[ 1 ] * b[ 0 ];
124 return sqrt(valx * valx + valy * valy);
134 return sqrt(valx * valx + valy * valy + valz * valz);
146 len =
sqrt(valx * valx + valy * valy + valz * valz);
148 proj_len = dir[ 0 ] * valx + dir[ 1 ] * valy + dir[ 2 ] * valz;
150 return sqrt(len * len - proj_len * proj_len);
180 return ((p[ 0 ] ==
q[ 0 ])
181 && (p[ 1 ] ==
q[ 1 ])
182 && (p[ 2 ] ==
q[ 2 ]));
189 dest[ 0 ] += coef * vec[ 0 ];
190 dest[ 1 ] += coef * vec[ 1 ];
191 dest[ 2 ] += coef * vec[ 2 ];
302 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
304 min_coords[ ind ] =
min(
a.min_coords[ ind ],
305 b.min_coords[ ind ]);
306 max_coords[ ind ] =
max(
a.max_coords[ ind ],
307 b.max_coords[ ind ]);
315 printf(
"__________________________________________\n");
317 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
319 printf(
"%d: [%g...%g]\n", ind, min_coords[ ind ],
321 diff = max_coords[ ind ] - min_coords[ ind ];
325 printf(
"volume = %g\n", prod);
326 printf(
"\\__________________________________________\n");
331 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
333 out[ ind ] = (min_coords[ ind ] + max_coords[ ind ]) / 2.0;
343 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
353 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
355 min_coords[ ind ] = 1e20;
356 max_coords[ ind ] = -1e20;
372 return min_coords[ coord ];
376 return max_coords[ coord ];
382 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
384 if (pnt[ ind ] < min_coords[ ind ])
386 min_coords[ ind ] = pnt[ ind ];
389 if (pnt[ ind ] > max_coords[ ind ])
391 max_coords[ ind ] = pnt[ ind ];
398 return max_coords[ dim ] - min_coords[ dim ];
405 for (
int ind = 1; ind <
GDIAM_DIM; ind++)
425 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
446 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
450 prod = coord * dir [ ind ];
451 val = coord * coord - prod * prod;
467 return min_coords[ dim ];
471 return max_coords[ dim ];
495 for (
int i = 0; i < 3; i++)
497 dir_1[i] = other.dir_1[i];
498 dir_2[i] = other.dir_2[i];
499 dir_3[i] = other.dir_3[i];
510 f_init = other.f_init;
515 for (
int i = 0; i < 3; i++)
517 dir_1[i] = other.dir_1[i];
518 dir_2[i] = other.dir_2[i];
519 dir_3[i] = other.dir_3[i];
530 f_init = other.f_init;
543 return len1 * len2 * len3;
556 memcpy(pnt_tmp, dir_1,
sizeof(dir_1));
558 memcpy(dir_1, dir_3,
sizeof(dir_3));
560 memcpy(dir_3, pnt_tmp,
sizeof(dir_3));
598 double a_coef,
double b_coef,
601 for (
int ind = 0; ind <
GDIAM_DIM; ind++)
602 out[ ind ] = a_coef * dir_1[ ind ]
603 + b_coef * dir_2[ ind ]
604 + c_coef * dir_3[ ind ];
638 printf(
"-----------------------------------------------\n");
647 printf(
"volume: %g\n",
volume());
648 printf(
"Directions:\n");
652 printf(
"prods: %g, %g, %g\n",
657 printf(
"--------------------------------------------------\n");
701 printf(
"should be all close to zero: %g, %g, %g\n",
808 int grid_size,
int sample_size);
810 int grid_size,
int sample_size);
gdiam_real volume() const
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
void pnt_init(gdiam_point pnt, gdiam_real x, gdiam_real y, gdiam_real z)
void pnt_zero(gdiam_point dst)
void init(const gdiam_point _p, const gdiam_point _q)
gdiam_real get_diam_proj(gdiam_point dir) const
gdiam_real pnt_distance_2d(gdiam_point_2d p, gdiam_point_2d q)
gdiam_real get_min_coord(int dim) const
void bound(const gdiam_point pnt)
gdiam_bbox gdiam_approx_mvbb_grid(gdiam_point *start, int size, int grid_size)
gdiam_bbox gdiam_approx_const_mvbb(gdiam_point *start, int size, gdiam_real eps, GBBox *p_ap_bbox)
void init(const gdiam_point _dir_1, const gdiam_point _dir_2, const gdiam_point _dir_3)
gdiam_real getLongestEdge() const
gdiam_real pnt_length(const gdiam_point pnt)
void gdiam_generate_orthonormal_base(gdiam_point in, gdiam_point out1, gdiam_point out2)
void center(gdiam_point out) const
const gdiam_real & max_coord(int coord) const
void update_diam(const gdiam_point _p, const gdiam_point _q)
void pnt_copy(gdiam_point_t dest, gdiam_point_t src)
void pnt_dump(gdiam_point_cnt pnt)
gdiam_real length_dim(int dim) const
void combine(gdiam_point out, double a_coef, double b_coef, double c_coef)
gdiam_bbox(const gdiam_bbox &other)
GPointPair gdiam_approx_diam(gdiam_point *start, int size, gdiam_real eps)
GPointPair gdiam_approx_diam_pair(gdiam_real *start, int size, gdiam_real eps)
void bound(const gdiam_point pnt)
double a(double t, double a0, double j)
gdiam_real get_diam() const
gdiam_real * gdiam_point_2d
void init(const GBBox &a, const GBBox &b)
gdiam_real pnt_distance(gdiam_point p, gdiam_point q)
gdiam_real get_max_coord(int dim) const
void pnt_cross_prod(const gdiam_point a, const gdiam_point b, const gdiam_point out)
gdiam_point get_dir(int ind)
void update_diam_simple(const gdiam_point _p, const gdiam_point _q)
gdiam_bbox gdiam_approx_mvbb(gdiam_point *start, int size, gdiam_real eps)
const gdiam_real & min_coord(int coord) const
gdiam_real pnt_dot_prod(gdiam_point_cnt a, gdiam_point_cnt b)
int getLongestDim() const
void pnt_scale_and_add(gdiam_point dest, gdiam_real coef, gdiam_point_cnt vec)
const gdiam_real * gdiam_point_cnt
void get_normalized_coordinates(gdiam_point in, gdiam_point out)
void set_third_dim_longest()
GPointPair gdiam_approx_diam_pair_UDM(gdiam_real *start, int size, gdiam_real eps)
gdiam_real gdiam_point_2d_t[2]
bool pnt_isEqual(const gdiam_point p, const gdiam_point q)
void init(const gdiam_point _p, const gdiam_point _q, const gdiam_point proj)
void gdiam_exchange(T &a, T &b)
gdiam_real gdiam_point_t[GDIAM_DIM]
void update_diam(const gdiam_point _p, const gdiam_point _q, const gdiam_point dir)
void dump_vertex(double sel1, double sel2, double sel3) const
gdiam_real volume() const
gdiam_point * gdiam_convert(gdiam_real *start, int size)
void pnt_normalize(gdiam_point pnt)
gdiam_bbox & operator=(const gdiam_bbox &other)
gdiam_bbox gdiam_approx_mvbb_grid_sample(gdiam_point *start, int size, int grid_size, int sample_size)
void init(const gdiam_point pnt)
void update_diam(GPointPair &pp)
void update_diam_simple(const gdiam_point _p, const gdiam_point _q, const gdiam_point dir)
void pnt_init_normalize(gdiam_point pnt, gdiam_real x, gdiam_real y, gdiam_real z)
void init(const GBBox &bb)