Sphere.cpp
Go to the documentation of this file.
1 #include "Sphere.h"
2 #include <MiscLib/Performance.h>
4 #include <GfxTL/MathHelper.h>
5 #ifdef DOPARALLEL
6 #include <omp.h>
7 #endif
8 
9 extern int dmat_solve(int n, int rhs_num, double a[]);
10 
11 void tetrahedron_circumsphere_3d(double tetra[3 * 4], double* r, double pc[3])
12 
13 //******************************************************************************
14 //
15 // Purpose:
16 //
17 // TETRAHEDRON_CIRCUMSPHERE_3D computes the circumsphere of a tetrahedron in 3D.
18 //
19 // Discussion:
20 //
21 // The circumsphere, or circumscribed sphere, of a tetrahedron is the sphere that
22 // passes through the four vertices. The circumsphere is not necessarily
23 // the smallest sphere that contains the tetrahedron.
24 //
25 // Surprisingly, the diameter of the sphere can be found by solving
26 // a 3 by 3 linear system. This is because the vectors P2 - P1,
27 // P3 - P1 and P4 - P1 are secants of the sphere, and each forms a
28 // right triangle with the diameter through P1. Hence, the dot product of
29 // P2 - P1 with that diameter is equal to the square of the length
30 // of P2 - P1, and similarly for P3 - P1 and P4 - P1. This determines
31 // the diameter vector originating at P1, and hence the radius and
32 // center.
33 //
34 // Modified:
35 //
36 // 10 August 2005
37 //
38 // Author:
39 //
40 // John Burkardt
41 //
42 // Reference:
43 //
44 // Adrian Bowyer and John Woodwark,
45 // A Programmer's Geometry,
46 // Butterworths, 1983.
47 //
48 // Parameters:
49 //
50 // Input, double TETRA[3*4], the vertices of the tetrahedron.
51 //
52 // Output, double *R, PC[3], the coordinates of the center of the
53 // circumscribed sphere, and its radius. If the linear system is
54 // singular, then R = -1, PC[] = 0.
55 //
56 {
57 # define DIM_NUM 3
58 # define RHS_NUM 1
59 
60  double a[DIM_NUM * (DIM_NUM + RHS_NUM)];
61  int info;
62  //
63  // Set up the linear system.
64  //
65  a[0 + 0 * 3] = tetra[0 + 1 * 3] - tetra[0 + 0 * 3];
66  a[0 + 1 * 3] = tetra[1 + 1 * 3] - tetra[1 + 0 * 3];
67  a[0 + 2 * 3] = tetra[2 + 1 * 3] - tetra[2 + 0 * 3];
68  a[0 + 3 * 3] = std::pow(tetra[0 + 1 * 3] - tetra[0 + 0 * 3], 2)
69  + std::pow(tetra[1 + 1 * 3] - tetra[1 + 0 * 3], 2)
70  + std::pow(tetra[2 + 1 * 3] - tetra[2 + 0 * 3], 2);
71 
72  a[1 + 0 * 3] = tetra[0 + 2 * 3] - tetra[0 + 0 * 3];
73  a[1 + 1 * 3] = tetra[1 + 2 * 3] - tetra[1 + 0 * 3];
74  a[1 + 2 * 3] = tetra[2 + 2 * 3] - tetra[2 + 0 * 3];
75  a[1 + 3 * 3] = std::pow(tetra[0 + 2 * 3] - tetra[0 + 0 * 3], 2)
76  + std::pow(tetra[1 + 2 * 3] - tetra[1 + 0 * 3], 2)
77  + std::pow(tetra[2 + 2 * 3] - tetra[2 + 0 * 3], 2);
78 
79  a[2 + 0 * 3] = tetra[0 + 3 * 3] - tetra[0 + 0 * 3];
80  a[2 + 1 * 3] = tetra[1 + 3 * 3] - tetra[1 + 0 * 3];
81  a[2 + 2 * 3] = tetra[2 + 3 * 3] - tetra[2 + 0 * 3];
82  a[2 + 3 * 3] = std::pow(tetra[0 + 3 * 3] - tetra[0 + 0 * 3], 2)
83  + std::pow(tetra[1 + 3 * 3] - tetra[1 + 0 * 3], 2)
84  + std::pow(tetra[2 + 3 * 3] - tetra[2 + 0 * 3], 2);
85  //
86  // Solve the linear system.
87  //
88  info = dmat_solve(DIM_NUM, RHS_NUM, a);
89  //
90  // If the system was singular, return a consolation prize.
91  //
92  if (info != 0)
93  {
94  *r = -1.0;
95  for (size_t i = 0; i < DIM_NUM; ++i)
96  {
97  pc[i] = 0;
98  }
99  //dvec_zero ( DIM_NUM, pc );
100  return;
101  }
102  //
103  // Compute the radius and center.
104  //
105  *r = 0.5 * std::sqrt
106  (a[0 + 3 * 3] * a[0 + 3 * 3]
107  + a[1 + 3 * 3] * a[1 + 3 * 3]
108  + a[2 + 3 * 3] * a[2 + 3 * 3]);
109 
110  pc[0] = tetra[0 + 0 * 3] + 0.5 * a[0 + 3 * 3];
111  pc[1] = tetra[1 + 0 * 3] + 0.5 * a[1 + 3 * 3];
112  pc[2] = tetra[2 + 0 * 3] + 0.5 * a[2 + 3 * 3];
113 
114  return;
115 # undef DIM_NUM
116 # undef RHS_NUM
117 }
118 
119 bool Midpoint(const Vec3f& p1, const Vec3f& n1, const Vec3f& p2, const Vec3f& n2,
120  Vec3f* mid)
121 {
122  float d1343, d4321, d1321, d4343, d2121;
123  float numer, denom, mua, mub;
124 
125  Vec3f p13 = p1 - p2;
126  // p43 = n2
127  // p21 = n1
128  d1343 = p13[0] * n2[0] + p13[1] * n2[1] + p13[2] * n2[2];
129  d4321 = n2[0] * n1[0] + n2[1] * n1[1] + n2[2] * n1[2];
130  d1321 = p13[0] * n1[0] + p13[1] * n1[1] + p13[2] * n1[2];
131  d4343 = n2[0] * n2[0] + n2[1] * n2[1] + n2[2] * n2[2];
132  d2121 = n1[0] * n1[0] + n1[1] * n1[1] + n1[2] * n1[2];
133 
134  denom = d2121 * d4343 - d4321 * d4321;
135  if (abs(denom) < 1e-6)
136  {
137  return false;
138  }
139  numer = d1343 * d4321 - d1321 * d4343;
140 
141  mua = numer / denom;
142  mub = (d1343 + d4321 * (mua)) / d4343;
143 
144  Vec3f pa, pb;
145  pa = p1 + mua * n1;
146  pb = p2 + mub * n2;
147  *mid = 0.5f * (pa + pb);
148  return true;
149 }
150 
152  : std::runtime_error("Invalid tetrahedon")
153 {}
154 
156 {}
157 
158 Sphere::Sphere(const Vec3f& center, float radius)
159  : m_center(center)
160  , m_radius(radius)
161 {}
162 
163 Sphere::Sphere(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3,
164  const Vec3f& p4)
165 {
166  if (!Init(p1, p2, p3, p4))
167  {
168  throw InvalidTetrahedonError();
169  }
170 }
171 
173 {
174  if (samples.size() < 4)
175  {
176  return false;
177  }
178  // get center
179  size_t c = samples.size() / 2;
180  m_center = Vec3f(0, 0, 0);
181  size_t midCount = 0;
182  for (size_t i = 0; i < c - 1; ++i)
183  for (size_t j = i + 1; j < c; ++j)
184  {
185  Vec3f mid;
186  if (!Midpoint(samples[i], samples[i + c], samples[j], samples[j + c], &mid))
187  {
188  continue;
189  }
190  m_center += mid;
191  ++midCount;
192  }
193  if (!midCount)
194  {
195  return false;
196  }
197  m_center /= midCount;
198  m_radius = 0;
199  for (size_t i = 0; i < c; ++i)
200  {
201  float d = (samples[i] - m_center).length();
202  m_radius += d;
203  }
204  m_radius /= c;
205  return true;
206 }
207 
208 bool Sphere::Init(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3,
209  const Vec3f& p4)
210 {
211  // convert to double array
212  double tetra[4 * 3];
213  for (size_t i = 0; i < 3; ++i)
214  {
215  tetra[0 * 3 + i] = p1[i];
216  }
217  for (size_t i = 0; i < 3; ++i)
218  {
219  tetra[1 * 3 + i] = p2[i];
220  }
221  for (size_t i = 0; i < 3; ++i)
222  {
223  tetra[2 * 3 + i] = p3[i];
224  }
225  for (size_t i = 0; i < 3; ++i)
226  {
227  tetra[3 * 3 + i] = p4[i];
228  }
229  double r, pc[3];
230  tetrahedron_circumsphere_3d(tetra, &r, pc);
231  if (r < 0)
232  {
233  return false;
234  }
235  m_radius = r;
236  m_center[0] = pc[0];
237  m_center[1] = pc[1];
238  m_center[2] = pc[2];
239  return true;
240 }
241 
242 bool Sphere::Init2(const Vec3f& p1, const Vec3f& p2, const Vec3f& n1,
243  const Vec3f& n2)
244 {
245  /*
246  Calculate the line segment PaPb that is the shortest route between
247  two lines P1P2 and P3P4. Calculate also the values of mua and mub where
248  Pa = P1 + mua (P2 - P1)
249  Pb = P3 + mub (P4 - P3)
250  Return FALSE if no solution exists.
251  */
252  float d1343, d4321, d1321, d4343, d2121;
253  float numer, denom, mua, mub;
254 
255  Vec3f p13 = p1 - p2;
256  // p43 = n2
257  // p21 = n1
258  d1343 = p13[0] * n2[0] + p13[1] * n2[1] + p13[2] * n2[2];
259  d4321 = n2[0] * n1[0] + n2[1] * n1[1] + n2[2] * n1[2];
260  d1321 = p13[0] * n1[0] + p13[1] * n1[1] + p13[2] * n1[2];
261  d4343 = n2[0] * n2[0] + n2[1] * n2[1] + n2[2] * n2[2];
262  d2121 = n1[0] * n1[0] + n1[1] * n1[1] + n1[2] * n1[2];
263 
264  denom = d2121 * d4343 - d4321 * d4321;
265  if (abs(denom) < 1e-6)
266  {
267  return false;
268  }
269  numer = d1343 * d4321 - d1321 * d4343;
270 
271  mua = numer / denom;
272  mub = (d1343 + d4321 * (mua)) / d4343;
273 
274  Vec3f pa, pb;
275  pa = p1 + mua * n1;
276  pb = p2 + mub * n2;
277 
278  // get the midpoint between pa and pb and make it the center
279  m_center = 0.5f * (pa + pb);
280  // make the radius the average of the two distances
281  float da = (p1 - m_center).length();
282  float db = (p2 - m_center).length();
283  m_radius = 0.5f * (da + db);
284  // do some plausability checks
285  // lets say the actual distance should not deviate by more than 10%
286  float dev = da / m_radius;
287  if (dev < 0.9f || dev > 1.1f)
288  {
289  return false;
290  }
291  dev = db / m_radius;
292  if (dev < 0.9f || dev > 1.1f)
293  {
294  return false;
295  }
296  // distance between pa and pb should not be greater than 10% of the radius
297  dev = (pa - pb).length() / m_radius;
298  if (dev > 0.1f)
299  {
300  return false;
301  }
302  return true;
303 }
304 
305 bool Sphere::Init(bool binary, std::istream* i)
306 {
307  if (binary)
308  {
309  i->read((char*)&m_center, sizeof(m_center));
310  i->read((char*)&m_radius, sizeof(m_radius));
311  }
312  else
313  {
314  for (size_t j = 0; j < 3; ++j)
315  {
316  (*i) >> m_center[j];
317  }
318  (*i) >> m_radius;
319  }
320  return true;
321 }
322 
323 void Sphere::Init(FILE* i)
324 {
325  fread(&m_center, sizeof(m_center), 1, i);
326  fread(&m_radius, sizeof(m_radius), 1, i);
327 }
328 
329 void Sphere::Init(float* array)
330 {
331  for (int i = 0; i < 3; i++)
332  {
333  m_center[i] = array[i];
334  }
335  m_radius = array[3];
336 }
337 
338 void Sphere::Project(const Vec3f& p, Vec3f* pp) const
339 {
340  *pp = p - m_center;
341  float l = pp->length();
342  *pp *= m_radius / l;
343  *pp += m_center;
344 }
345 
346 const Vec3f& Sphere::Center() const
347 {
348  return m_center;
349 }
350 
351 float Sphere::Radius() const
352 {
353  return m_radius;
354 }
355 
356 float SphereDistance(const float* param, const float* x)
357 {
358  float s = x[0] - param[0];
359  s *= s;
360  for (unsigned int i = 1; i < 3; ++i)
361  {
362  float ss = x[i] - param[i];
363  s += ss * ss;
364  }
365  return std::sqrt(s) - param[3];
366 }
367 
368 void SphereDistanceDerivatives(const float* param, const float* x,
369  float* gradient)
370 {
371  float s[3];
372  s[0] = x[0] - param[0];
373  float sl = s[0] * s[0];
374  for (unsigned int i = 1; i < 3; ++i)
375  {
376  s[i] = x[i] - param[i];
377  sl += s[i] * s[i];
378  }
379  sl = std::sqrt(sl);
380  gradient[0] = -s[0] / sl;
381  gradient[1] = -s[1] / sl;
382  gradient[2] = -s[2] / sl;
383  gradient[3] = -1;
384 }
385 
386 void NormalizeSphereParams(float* param)
387 {}
388 
392 {
393  bool retVal = LeastSquaresFit(GfxTL::IndexIterate(begin, pc.begin()),
394  GfxTL::IndexIterate(end, pc.begin()));
395  return retVal;
396 }
397 
399  const MiscLib::Vector< float >& weights, Sphere* is)
400 {
401  Vec3f center(0, 0, 0);
402  float radius = 0;
403  for (size_t i = 0; i < spheres.size(); ++i)
404  {
405  center += weights[i] * spheres[i].Center();
406  radius += weights[i] * spheres[i].Radius();
407  }
408  is->Center(center);
409  is->Radius(radius);
410  return true;
411 }
412 
413 void Sphere::Serialize(bool binary, std::ostream* o) const
414 {
415  if (binary)
416  {
417  o->write((const char*)&m_center, sizeof(m_center));
418  o->write((const char*)&m_radius, sizeof(m_radius));
419  }
420  else
421  {
422  (*o) << m_center[0] << " " << m_center[1] << " " << m_center[2] << " "
423  << m_radius << " ";
424  }
425 }
426 
428 {
429  return sizeof(Vec3f)
430  + sizeof(float);
431 }
432 
434 {
435  return 4;
436 }
437 
438 void Sphere::Serialize(FILE* o) const
439 {
440  fwrite(&m_center, sizeof(m_center), 1, o);
441  fwrite(&m_radius, sizeof(m_radius), 1, o);
442 }
443 
444 void Sphere::Serialize(float* array) const
445 {
446  for (int i = 0; i < 3; i++)
447  {
448  array[i] = m_center[i];
449  }
450  array[3] = m_radius;
451 }
452 
453 
454 void Sphere::Transform(float scale, const Vec3f& translate)
455 {
456  m_center *= scale;
457  m_center += translate;
458  m_radius *= scale;
459 }
460 
462  const Vec3f& planeNormal)
463  : m_sphere(sphere)
464  , m_planeNormal(planeNormal)
465  , m_hcs(GfxTL::Vector3Df(planeNormal))
466 {}
467 
469  const Vec3f& planeNormal)
470 {
471  m_sphere = sphere;
472  m_planeNormal = planeNormal;
473  m_hcs.FromNormal(planeNormal[0], planeNormal[1], planeNormal[2]);
474 }
475 
477  std::pair< float, float >* param) const
478 {
479  // convert to hemisphere coordinates
480  Vec3f s = p - m_sphere.Center();
481  s.normalize();
482  Vec3f hs;
483  hs[0] = s.dot(m_hcs[0].Data());
484  hs[1] = s.dot(m_hcs[1].Data());
485  hs[2] = s.dot(m_planeNormal);
486  float ret = hs[2];
487  hs[2] = abs(hs[2]);
488  std::pair< float, float > inDisk;
489  Hemisphere2Disk(hs, &inDisk);
490  Disk2Square(inDisk, param);
491  return ret;
492 }
493 
495  const std::pair< float, float >& param, bool lower, Vec3f* p) const
496 {
497  if (param.first < -0.1 || param.first > 1.1
498  || param.second < -0.1 || param.second > 1.1)
499  {
500  return false;
501  }
502  std::pair< float, float > clampedParam;
503  clampedParam.first = GfxTL::Math< float >::Clamp(param.first, 0, 1);
504  clampedParam.second = GfxTL::Math< float >::Clamp(param.second, 0, 1);
505  std::pair< float, float > inDisk;
506  Square2Disk(clampedParam, &inDisk);
507  Vec3f s;
508  Disk2Hemisphere(inDisk, &s);
509  *p = Vec3f((s[0] * m_hcs[0] + s[1] * m_hcs[1] +
510  GfxTL::Vector3Df((lower ? -1 : 1) * s[2] * m_planeNormal)).Data());
511  *p *= m_sphere.Radius();
512  *p += m_sphere.Center();
513  return true;
514 }
515 
517  const std::pair< float, float >& param, bool lower, Vec3f* p,
518  Vec3f* n) const
519 {
520  if (param.first < -0.1 || param.first > 1.1
521  || param.second < -0.1 || param.second > 1.1)
522  {
523  return false;
524  }
525  std::pair< float, float > clampedParam;
526  clampedParam.first = GfxTL::Math< float >::Clamp(param.first, 0, 1);
527  clampedParam.second = GfxTL::Math< float >::Clamp(param.second, 0, 1);
528  std::pair< float, float > inDisk;
529  Square2Disk(clampedParam, &inDisk);
530  Vec3f s;
531  Disk2Hemisphere(inDisk, &s);
532  if (lower)
533  {
534  s[2] *= -1;
535  }
536  *n = Vec3f((s[0] * m_hcs[0] + s[1] * m_hcs[1] +
537  GfxTL::Vector3Df(s[2] * m_planeNormal)).Data());
538  *p = m_sphere.Radius() * (*n);
539  *p += m_sphere.Center();
540  return true;
541 }
542 
544  const GfxTL::MatrixXX< 3, 3, float >& rot, const GfxTL::Vector3Df& trans)
545 {
546  m_sphere = Sphere(Vec3f((rot * GfxTL::Vector3Df(m_sphere.Center())
547  + trans).Data()), m_sphere.Radius());
548  m_planeNormal = Vec3f((rot * GfxTL::Vector3Df(m_planeNormal)).Data());
549  m_hcs[0] = rot * m_hcs[0];
550  m_hcs[1] = rot * m_hcs[1];
551 }
552 
554 {
555  hcs0->setValue(m_hcs[0]);
556  hcs1->setValue(m_hcs[1]);
557  hcs2->setValue(m_hcs[2]);
558 }
559 
560 
561 void SphereAsSquaresParametrization::Hemisphere2Disk(const Vec3f& p,
562  std::pair< float, float >* inDisk) const
563 {
564  inDisk->first = std::sqrt(1 - p[2]);
565  inDisk->second = std::atan2(p[1], p[0]);
566 }
567 
568 void SphereAsSquaresParametrization::Disk2Square(
569  const std::pair< float, float >& inDisk,
570  std::pair< float, float >* inSquare) const
571 {
572  float r = inDisk.first;
573  float phi = inDisk.second;
574  float a, b;
575 
576  if (phi < float(-M_PI / 4.0))
577  {
578  phi += float(2 * M_PI);
579  }
580 
581  if (phi < float(M_PI / 4.0))
582  {
583  a = r;
584  b = phi * a / float(M_PI / 4.0);
585  }
586  else if (phi < float(3 * M_PI / 4.0))
587  {
588  b = r;
589  a = -(phi - float(M_PI / 2.0)) * b / float(M_PI / 4.0);
590  }
591  else if (phi < float(5 * M_PI / 4.0))
592  {
593  a = -r;
594  b = (phi - float(M_PI)) * a / float(M_PI / 4.0);
595  }
596  else
597  {
598  b = -r;
599  a = -(phi - float(3 * M_PI / 2.0)) * b / float(M_PI / 4.0);
600  }
601 
602  inSquare->first = (a + float(1.0)) / float(2.0);
603  inSquare->second = (b + float(1.0)) / float(2.0);
604 }
605 
606 void SphereAsSquaresParametrization::Square2Disk(
607  const std::pair< float, float >& inSquare,
608  std::pair< float, float >* inDisk) const
609 {
610  float phi, r;
611  float a = 2 * inSquare.first - 1;
612  float b = 2 * inSquare.second - 1;
613 
614  if (a > -b)
615  {
616  if (a > b)
617  {
618  r = a;
619  phi = float(M_PI / 4.0) * (b / a);
620  }
621  else
622  {
623  r = b;
624  phi = float(M_PI / 4.0) * (2 - (a / b));
625  }
626  }
627  else
628  {
629  if (a < b)
630  {
631  r = -a;
632  phi = float(M_PI / 4.0) * (4 + (b / a));
633  }
634  else
635  {
636  r = -b;
637  if (b != 0)
638  {
639  phi = float(M_PI / 4.0) * (6 - (a / b));
640  }
641  else
642  {
643  phi = 0;
644  }
645  }
646  }
647 
648  inDisk->first = r;
649  inDisk->second = phi;
650 }
651 
652 void SphereAsSquaresParametrization::Disk2Hemisphere(
653  const std::pair< float, float >& inDisk, Vec3f* p) const
654 {
655  (*p)[0] = inDisk.first * std::sqrt(2 - inDisk.first * inDisk.first)
656  * std::cos(inDisk.second);
657  (*p)[1] = inDisk.first * std::sqrt(2 - inDisk.first * inDisk.first)
658  * std::sin(inDisk.second);
659  (*p)[2] = 1 - inDisk.first * inDisk.first;
660 }
GfxTL::sqrt
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
Definition: VectorXD.h:662
GfxTL::VectorXD
Definition: MatrixXX.h:21
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
Sphere.h
Vec3f
Definition: basic.h:16
Performance.h
Sphere::SerializedSize
static size_t SerializedSize()
Definition: Sphere.cpp:427
DIM_NUM
#define DIM_NUM
SphereAsSquaresParametrization::InSpace
bool InSpace(const std::pair< float, float > &param, bool lower, Vec3f *p) const
Definition: Sphere.cpp:494
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
Vec3f::length
float length() const
Definition: basic.h:120
Sphere::Init2
bool Init2(const Vec3f &p1, const Vec3f &p2, const Vec3f &n1, const Vec3f &n2)
Definition: Sphere.cpp:242
GfxTL::MatrixXX
Definition: MatrixXX.h:25
tetrahedron_circumsphere_3d
void tetrahedron_circumsphere_3d(double tetra[3 *4], double *r, double pc[3])
Definition: Sphere.cpp:11
MiscLib::Vector
Definition: Vector.h:19
NormalizeSphereParams
void NormalizeSphereParams(float *param)
Definition: Sphere.cpp:386
InvalidTetrahedonError
Definition: Sphere.h:21
GfxTL::Vector3Df
VectorXD< 3, float > Vector3Df
Definition: VectorXD.h:676
MiscLib::Vector::size
size_type size() const
Definition: Vector.h:212
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
M_PI
#define M_PI
Definition: MathTools.h:17
Sphere::Serialize
void Serialize(bool binary, std::ostream *o) const
Definition: Sphere.cpp:413
SphereDistance
float SphereDistance(const float *param, const float *x)
Definition: Sphere.cpp:356
InvalidTetrahedonError::InvalidTetrahedonError
InvalidTetrahedonError()
Definition: Sphere.cpp:151
GfxTL::IndexIterate
IndexedIterator< IndexIteratorT, IteratorT > IndexIterate(IndexIteratorT idxIt, IteratorT it)
Definition: IndexedIterator.h:154
RHS_NUM
#define RHS_NUM
GfxTL::Math::Clamp
static ScalarT Clamp(ScalarT s, ScalarT bottom, ScalarT top)
Definition: MathHelper.h:36
SphereDistanceDerivatives
void SphereDistanceDerivatives(const float *param, const float *x, float *gradient)
Definition: Sphere.cpp:368
GfxTL
Definition: AABox.h:8
Sphere::Init
bool Init(const MiscLib::Vector< Vec3f > &samples)
Definition: Sphere.cpp:172
SphereAsSquaresParametrization::SphereAsSquaresParametrization
SphereAsSquaresParametrization()
Definition: Sphere.h:309
IndexedIterator.h
Sphere::Center
const Vec3f & Center() const
Definition: Sphere.cpp:346
PointCloud
Definition: PointCloud.h:69
float
#define float
Definition: 16_Level.h:22
SphereAsSquaresParametrization::Transform
void Transform(const GfxTL::MatrixXX< 3, 3, float > &rot, const GfxTL::Vector3Df &trans)
Definition: Sphere.cpp:543
std
Definition: Application.h:66
Vec3f::setValue
Vec3f & setValue(const float v[3])
Definition: basic.h:42
dmat_solve
int dmat_solve(int n, int rhs_num, double a[])
Definition: solve.cpp:7
Sphere
Definition: Sphere.h:27
Sphere::Sphere
Sphere()
Definition: Sphere.cpp:155
Sphere::SerializedFloatSize
static size_t SerializedFloatSize()
Definition: Sphere.cpp:433
GfxTL::Vec3f
VectorXD< 3, float > Vec3f
Definition: VectorXD.h:691
Midpoint
bool Midpoint(const Vec3f &p1, const Vec3f &n1, const Vec3f &p2, const Vec3f &n2, Vec3f *mid)
Definition: Sphere.cpp:119
Sphere::LeastSquaresFit
bool LeastSquaresFit(const PointCloud &pc, MiscLib::Vector< size_t >::const_iterator begin, MiscLib::Vector< size_t >::const_iterator end)
Definition: Sphere.cpp:389
pc
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics Blackwell June If you use this software you should cite the aforementioned paper in any resulting publication Please send comments or bug reports to Ruwen Roland BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE Example usage This section shows how to use the library to detect the shapes in a point cloud PointCloud pc
Definition: ReadMe.txt:68
Sphere::Project
void Project(const Vec3f &p, Vec3f *pp) const
Definition: Sphere.cpp:338
MathHelper.h
SphereAsSquaresParametrization::Parameters
float Parameters(const Vec3f &p, std::pair< float, float > *param) const
Definition: Sphere.cpp:476
Sphere::Interpolate
static bool Interpolate(const MiscLib::Vector< Sphere > &spheres, const MiscLib::Vector< float > &weights, Sphere *is)
Definition: Sphere.cpp:398
Sphere::Radius
float Radius() const
Definition: Sphere.cpp:351
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
SphereAsSquaresParametrization::Init
void Init(const Sphere &sphere, const Vec3f &planeNormal)
Definition: Sphere.cpp:468
Sphere::Transform
void Transform(float scale, const Vec3f &translate)
Definition: Sphere.cpp:454
SphereAsSquaresParametrization::HyperplaneCoordinateSystem
void HyperplaneCoordinateSystem(Vec3f *hcs0, Vec3f *hcs1, Vec3f *hcs2) const
Definition: Sphere.cpp:553