Triangle.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2016 Imperial College London
5  * Copyright 2013-2016 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef MIRTK_Triangle_H
21 #define MIRTK_Triangle_H
22 
23 #include "mirtk/Math.h"
24 #include "mirtk/Vector3.h"
25 #include "mirtk/Matrix3x3.h"
26 #include "mirtk/VtkMath.h"
27 
28 
29 namespace mirtk {
30 
31 
32 /**
33  * Auxiliary class/static helper functions for triangulated surface meshes
34  */
35 class Triangle
36 {
37 public:
38 
39  /// Compute center point of triangle
40  ///
41  /// \param[in] a Position of triangle vertex A.
42  /// \param[in] b Position of triangle vertex B.
43  /// \param[in] c Position of triangle vertex C.
44  /// \param[out] center Position of triangle center.
45  static void Center(const double a[3], const double b[3], const double c[3], double center[3]);
46 
47  /// Compute center point of triangle
48  ///
49  /// \param[in] a Position of triangle vertex A.
50  /// \param[in] b Position of triangle vertex B.
51  /// \param[in] c Position of triangle vertex C.
52  /// \param[out] center Position of triangle center.
53  ///
54  /// \returns Radius of bounding sphere with optionally returned \p center point.
55  static double BoundingSphereRadius(const double a[3], const double b[3], const double c[3], double *center = nullptr);
56 
57  /// Compute normal direction of triangle
58  ///
59  /// \param[in] a Position of triangle vertex A.
60  /// \param[in] b Position of triangle vertex B.
61  /// \param[in] c Position of triangle vertex C.
62  /// \param[out] n Non-normalized triangle normal vector.
63  /// The length of the resulting vector equals twice the triangle area.
64  static void NormalDirection(const double a[3], const double b[3], const double c[3], double n[3]);
65 
66  /// Partial derivatives of normal direction w.r.t. position of vertex A
67  ///
68  /// \param[in] a Position of triangle vertex A.
69  /// \param[in] b Position of triangle vertex B.
70  /// \param[in] c Position of triangle vertex C.
71  ///
72  /// \returns Partial derivatives of normal direction components w.r.t. coordinates of vertex A.
73  static Matrix3x3 NormalDirectionJacobian(const double a[3], const double b[3], const double c[3]);
74 
75  /// Compute normal of triangle
76  ///
77  /// \param[in] a Position of triangle vertex A.
78  /// \param[in] b Position of triangle vertex B.
79  /// \param[in] c Position of triangle vertex C.
80  /// \param[out] n Triangle normal vector.
81  static void Normal(const double a[3], const double b[3], const double c[3], double n[3]);
82 
83  /// Partial derivatives of normal w.r.t. coordinates of vertex A
84  ///
85  /// \param[in] a Position of triangle vertex A.
86  /// \param[in] b Position of triangle vertex B.
87  /// \param[in] c Position of triangle vertex C.
88  ///
89  /// \returns Partial derivatives of normal components w.r.t. coordinates of vertex A.
90  static Matrix3x3 NormalJacobian(const double a[3], const double b[3], const double c[3]);
91 
92  /// Partial derivatives of normal w.r.t. coordinates of vertex A
93  ///
94  /// \param[in] a Position of triangle vertex A.
95  /// \param[in] b Position of triangle vertex B.
96  /// \param[in] c Position of triangle vertex C.
97  /// \param[in] dn Partial derivatives of normal direction vector.
98  ///
99  /// \returns Partial derivatives of normal components w.r.t. coordinates of vertex A.
100  static Matrix3x3 NormalJacobian(const double a[3], const double b[3], const double c[3], const Matrix3x3 &dn);
101 
102  /// Partial derivatives of normal w.r.t. coordinates of vertex A
103  ///
104  /// \param[in] n Triangle normal vector, i.e., normalized direction vector.
105  /// \param[in] dn Partial derivatives of normal direction vector.
106  ///
107  /// \returns Partial derivatives of normal components w.r.t. coordinates of vertex A.
108  static Matrix3x3 NormalJacobian(const double n[3], const Matrix3x3 &dn);
109 
110  /// Partial derivatives of normal w.r.t. coordinates of vertex A
111  ///
112  /// \param[in] n Triangle normal vector, i.e., normalized direction vector.
113  /// \param[in] dn Partial derivatives of normal direction vector.
114  ///
115  /// \returns Partial derivatives of normal components w.r.t. coordinates of vertex A.
116  static Matrix3x3 NormalJacobian(const Vector3 &n, const Matrix3x3 &dn);
117 
118  /// Compute twice the area of triangle
119  ///
120  /// \param[in] a Position of triangle vertex A.
121  /// \param[in] b Position of triangle vertex B.
122  /// \param[in] c Position of triangle vertex C.
123  ///
124  /// \returns Twice the area of the triangle.
125  static double DoubleArea(const double a[3], const double b[3], const double c[3]);
126 
127  /// Partial derivatives of twice the triangle area w.r.t. coordinates of vertex A
128  ///
129  /// \param[in] a Position of triangle vertex A.
130  /// \param[in] b Position of triangle vertex B.
131  /// \param[in] c Position of triangle vertex C.
132  ///
133  /// \returns Partial derivatives of twice the triangle area w.r.t. coordinates of vertex A.
134  static Vector3 DoubleAreaGradient(const double a[3], const double b[3], const double c[3]);
135 
136  /// Compute area of triangle
137  ///
138  /// \param[in] a Position of triangle vertex A.
139  /// \param[in] b Position of triangle vertex B.
140  /// \param[in] c Position of triangle vertex C.
141  ///
142  /// \returns Area of triangle.
143  static double Area(const double a[3], const double b[3], const double c[3]);
144 
145  /// Partial derivative of triangle area w.r.t. coordinates of vertex A
146  ///
147  /// \param[in] a Position of triangle vertex A.
148  /// \param[in] b Position of triangle vertex B.
149  /// \param[in] c Position of triangle vertex C.
150  ///
151  /// \returns Partial derivatives of triangle area w.r.t. coordinates of vertex A.
152  static Vector3 AreaGradient(const double a[3], const double b[3], const double c[3]);
153 
154  /// Compute area of triangle in 2D
155  ///
156  /// \param[in] a Position of triangle vertex A.
157  /// \param[in] b Position of triangle vertex B.
158  /// \param[in] c Position of triangle vertex C.
159  ///
160  /// \returns Signed area of triangle.
161  static double SignedArea2D(const double a[2], const double b[2], const double c[2]);
162 
163  /// Compute twice the area of triangle in 2D
164  ///
165  /// \param[in] a Position of triangle vertex A.
166  /// \param[in] b Position of triangle vertex B.
167  /// \param[in] c Position of triangle vertex C.
168  ///
169  /// \returns Twice the signed area of the triangle.
170  static double DoubleSignedArea2D(const double a[2], const double b[2], const double c[2]);
171 
172  /// Compute area of triangle in 2D
173  ///
174  /// \param[in] a Position of triangle vertex A.
175  /// \param[in] b Position of triangle vertex B.
176  /// \param[in] c Position of triangle vertex C.
177  ///
178  /// \returns Area of triangle.
179  static double Area2D(const double a[2], const double b[2], const double c[2]);
180 
181  /// Compute twice the area of triangle in 2D
182  ///
183  /// \param[in] a Position of triangle vertex A.
184  /// \param[in] b Position of triangle vertex B.
185  /// \param[in] c Position of triangle vertex C.
186  ///
187  /// \returns Twice the area of the triangle.
188  static double DoubleArea2D(const double a[2], const double b[2], const double c[2]);
189 
190  /// Compute cotangent of angle ABC
191  ///
192  /// \param[in] a Position of triangle vertex A.
193  /// \param[in] b Position of triangle vertex B.
194  /// \param[in] c Position of triangle vertex C.
195  ///
196  /// \returns Cotangent of angle ABC (equals cotangent of angle CBA).
197  static double Cotangent(double a[3], double b[3], double c[3]);
198 
199  /// Compute angle at triangle corners
200  ///
201  /// \param[in] a Position of triangle vertex A.
202  /// \param[in] b Position of triangle vertex B.
203  /// \param[in] c Position of triangle vertex C.
204  /// \param[out] angle Angles at triangle vertices in radians.
205  static void Angles(const double a[3], const double b[3], const double c[3], double angle[3]);
206 
207  /// Compute minimum angle at triangle vertices
208  ///
209  /// \return Minimum angle in radians.
210  static double MinAngle(const double a[3], const double b[3], const double c[3]);
211 
212  /// Compute maximum angle at triangle corners
213  ///
214  /// \return Maximum angle in radians.
215  static double MaxAngle(const double a[3], const double b[3], const double c[3]);
216 
217  /// Tests whether two triangles intersect each other
218  static bool TriangleTriangleIntersection(const double a1[3], const double b1[3], const double c1[3],
219  const double a2[3], const double b2[3], const double c2[3]);
220 
221  /// Tests whether two triangles intersect each other
222  static bool TriangleTriangleIntersection(const double a1[3], const double b1[3], const double c1[3],
223  const double a2[3], const double b2[3], const double c2[3],
224  int &coplanar, double *p1, double *p2);
225 
226  /// Compute distance between triangle center points
227  static double DistanceBetweenCenters(const double a1[3], const double b1[3], const double c1[3],
228  const double a2[3], const double b2[3], const double c2[3],
229  double *p1, double *p2);
230 
231  /// Compute distance between closest corner points of two triangles
232  static double DistanceBetweenCorners(const double a1[3], const double b1[3], const double c1[3],
233  const double a2[3], const double b2[3], const double c2[3],
234  double *p1, double *p2);
235 
236  /// Compute distance between closest points of two triangles
237  static double DistanceBetweenTriangles(const double a1[3], const double b1[3], const double c1[3], const double n1[3],
238  const double a2[3], const double b2[3], const double c2[3], const double n2[3],
239  double *p1, double *p2);
240 
241  /// Compute distance between closest points of two triangles
242  static double DistanceBetweenTriangles(const double a1[3], const double b1[3], const double c1[3],
243  const double a2[3], const double b2[3], const double c2[3],
244  double *p1, double *p2);
245 
246 };
247 
248 
249 ////////////////////////////////////////////////////////////////////////////////
250 // Inline definitions
251 ////////////////////////////////////////////////////////////////////////////////
252 
253 // =============================================================================
254 // Center
255 // =============================================================================
256 
257 //----------------------------------------------------------------------------
258 inline void Triangle::Center(const double a[3], const double b[3], const double c[3], double center[3])
259 {
260  center[0] = (a[0] + b[0] + c[0]) / 3.0;
261  center[1] = (a[1] + b[1] + c[1]) / 3.0;
262  center[2] = (a[2] + b[2] + c[2]) / 3.0;
263 }
264 
265 //----------------------------------------------------------------------------
266 inline double Triangle::BoundingSphereRadius(const double a[3], const double b[3], const double c[3], double *center)
267 {
268  double p[3];
269  Center(a, b, c, p);
270  if (center) memcpy(center, p, 3 * sizeof(double));
271  return sqrt(max(max(vtkMath::Distance2BetweenPoints(a, p),
272  vtkMath::Distance2BetweenPoints(b, p)),
273  vtkMath::Distance2BetweenPoints(c, p)));
274 }
275 
276 // =============================================================================
277 // Normals
278 // =============================================================================
279 
280 // -----------------------------------------------------------------------------
281 inline void Triangle::NormalDirection(const double a[3], const double b[3], const double c[3], double n[3])
282 {
283  double ab[3], ac[3];
284  vtkMath::Subtract(b, a, ab);
285  vtkMath::Subtract(c, a, ac);
286  vtkMath::Cross(ab, ac, n);
287 }
288 
289 // -----------------------------------------------------------------------------
290 inline void Triangle::Normal(const double a[3], const double b[3], const double c[3], double n[3])
291 {
292  double l;
293  NormalDirection(a, b, c, n);
294  if ((l = vtkMath::Norm(n)) != 0.) {
295  n[0] /= l, n[1] /= l, n[2] /= l;
296  }
297 }
298 
299 // =============================================================================
300 // Area
301 // =============================================================================
302 
303 // -----------------------------------------------------------------------------
304 inline double Triangle::DoubleArea(const double a[3], const double b[3], const double c[3])
305 {
306  double n[3];
307  NormalDirection(a, b, c, n);
308  return vtkMath::Norm(n);
309 }
310 
311 // -----------------------------------------------------------------------------
312 inline double Triangle::Area(const double a[3], const double b[3], const double c[3])
313 {
314  return .5 * DoubleArea(a, b, c);
315 }
316 
317 // -----------------------------------------------------------------------------
318 inline double Triangle::DoubleSignedArea2D(const double a[2], const double b[2], const double c[2])
319 {
320  return (a[0]*b[1] - a[1]*b[0]) + (b[0]*c[1] - b[1]*c[0]) + (c[0]*a[1] - c[1]*a[0]);
321 }
322 
323 // -----------------------------------------------------------------------------
324 inline double Triangle::SignedArea2D(const double a[2], const double b[2], const double c[2])
325 {
326  return .5 * DoubleSignedArea2D(a, b, c);
327 }
328 
329 // -----------------------------------------------------------------------------
330 inline double Triangle::DoubleArea2D(const double a[2], const double b[2], const double c[2])
331 {
332  return abs(DoubleSignedArea2D(a, b, c));
333 }
334 
335 // -----------------------------------------------------------------------------
336 inline double Triangle::Area2D(const double a[2], const double b[2], const double c[2])
337 {
338  return abs(SignedArea2D(a, b, c));
339 }
340 
341 // =============================================================================
342 // Angles
343 // =============================================================================
344 
345 // -----------------------------------------------------------------------------
346 inline void Triangle::Angles(const double a[3], const double b[3], const double c[3], double angle[3])
347 {
348  const double ab2 = vtkMath::Distance2BetweenPoints(a, b), ab = sqrt(ab2);
349  const double ac2 = vtkMath::Distance2BetweenPoints(a, c), ac = sqrt(ac2);
350  const double bc2 = vtkMath::Distance2BetweenPoints(b, c), bc = sqrt(bc2);
351  angle[0] = acos((ab2 + ac2 - bc2) / (2.0 * ab * ac));
352  angle[1] = acos((ab2 + bc2 - ac2) / (2.0 * ab * bc));
353  angle[2] = acos((ac2 + bc2 - ab2) / (2.0 * ac * bc));
354 }
355 
356 // -----------------------------------------------------------------------------
357 inline double Triangle::MinAngle(const double a[3], const double b[3], const double c[3])
358 {
359  double angle[3];
360  Angles(a, b, c, angle);
361  return min(min(angle[0], angle[1]), angle[2]);
362 }
363 
364 // -----------------------------------------------------------------------------
365 inline double Triangle::MaxAngle(const double a[3], const double b[3], const double c[3])
366 {
367  double angle[3];
368  Angles(a, b, c, angle);
369  return max(max(angle[0], angle[1]), angle[2]);
370 }
371 
372 // -----------------------------------------------------------------------------
373 // Meyer et al. (2002). Generalized Barycentric Coordinates on Irregular Polygons.
374 inline double Triangle::Cotangent(double a[3], double b[3], double c[3])
375 {
376  double ba[3], bc[3], n[3];
377  vtkMath::Subtract(a, b, ba);
378  vtkMath::Subtract(c, b, bc);
379  vtkMath::Cross(ba, bc, n);
380  return vtkMath::Dot(ba, bc) / vtkMath::Norm(n);
381 }
382 
383 // =============================================================================
384 // Derivatives
385 // =============================================================================
386 
387 // -----------------------------------------------------------------------------
388 inline Matrix3x3 Triangle
389 ::NormalDirectionJacobian(const double a[3], const double b[3], const double c[3])
390 {
391  // - Derivative of ab x ac w.r.t. ab:
392  // [ 0., b[2] - a[2], a[1] - b[1];
393  // a[2] - b[2], 0., b[0] - a[0];
394  // b[1] - a[1], a[0] - b[0], 0. ]
395  // - Derivative of ab x ac w.r.t. ac:
396  // [ 0., a[2] - c[2], c[1] - a[1];
397  // c[2] - a[2], 0., a[0] - c[0];
398  // a[1] - c[1], c[0] - a[0], 0.]
399  // - Dervative of ab w.r.t. a: -I
400  // - Dervative of ac w.r.t. a: -I
401  //
402  // Apply chain rule to obtain total derivative of ab x ac w.r.t. a.
403  // This results in the following three subtractions and negations.
404  const double m01 = c[2] - b[2];
405  const double m02 = b[1] - c[1];
406  const double m12 = c[0] - b[0];
407  return Matrix3x3(0., m01, m02, -m01, 0., m12, -m02, -m12, 0.);
408 }
409 
410 // -----------------------------------------------------------------------------
411 inline Matrix3x3 Triangle
412 ::NormalJacobian(const Vector3 &n, const Matrix3x3 &dn)
413 {
414  const double l2 = n.SquaredLength();
415  if (l2 == 0.) return Matrix3x3(0.);
416 
417  const double l = sqrt(l2);
418  const double l3 = l2 * l;
419  const double d = 1. / l;
420 
421  const double m00 = n[0] * n[0] / l3;
422  const double m01 = n[0] * n[1] / l3;
423  const double m02 = n[0] * n[2] / l3;
424  const double m11 = n[1] * n[1] / l3;
425  const double m12 = n[1] * n[2] / l3;
426  const double m22 = n[2] * n[2] / l3;
427 
428  return Matrix3x3(m00 + d, m01, m02,
429  m01, m11 + d, m12,
430  m02, m12, m22 + d) * dn;
431 }
432 
433 // -----------------------------------------------------------------------------
434 inline Matrix3x3 Triangle
435 ::NormalJacobian(const double n[3], const Matrix3x3 &dn)
436 {
437  const double l2 = vtkMath::Dot(n, n);
438  if (l2 == 0.) return Matrix3x3(0.);
439 
440  const double l = sqrt(l2);
441  const double l3 = l2 * l;
442  const double d = 1. / l;
443 
444  const double m00 = n[0] * n[0] / l3;
445  const double m01 = n[0] * n[1] / l3;
446  const double m02 = n[0] * n[2] / l3;
447  const double m11 = n[1] * n[1] / l3;
448  const double m12 = n[1] * n[2] / l3;
449  const double m22 = n[2] * n[2] / l3;
450 
451  return Matrix3x3(m00 + d, m01, m02,
452  m01, m11 + d, m12,
453  m02, m12, m22 + d) * dn;
454 }
455 
456 // -----------------------------------------------------------------------------
457 inline Matrix3x3 Triangle
458 ::NormalJacobian(const double a[3], const double b[3], const double c[3], const Matrix3x3 &dn)
459 {
460  double n[3];
461  Normal(a, b, c, n);
462  return NormalJacobian(n, dn);
463 }
464 
465 // -----------------------------------------------------------------------------
466 inline Matrix3x3 Triangle
467 ::NormalJacobian(const double a[3], const double b[3], const double c[3])
468 {
469  return NormalJacobian(a, b, c, NormalDirectionJacobian(a, b, c));
470 }
471 
472 // -----------------------------------------------------------------------------
473 inline Vector3 Triangle
474 ::DoubleAreaGradient(const double a[3], const double b[3], const double c[3])
475 {
476  double n[3];
477  Normal(a, b, c, n);
478  return - Vector3(n) * NormalDirectionJacobian(a, b, c);
479 }
480 
481 // -----------------------------------------------------------------------------
482 inline Vector3 Triangle
483 ::AreaGradient(const double a[3], const double b[3], const double c[3])
484 {
485  return .5 * DoubleAreaGradient(a, b, c);
486 }
487 
488 // =============================================================================
489 // Distance between two triangles
490 // =============================================================================
491 
492 // -----------------------------------------------------------------------------
493 /// Compute distance between two triangles
494 inline double Triangle
495 ::DistanceBetweenCenters(const double a1[3], const double b1[3], const double c1[3],
496  const double a2[3], const double b2[3], const double c2[3],
497  double *p1, double *p2)
498 {
499  Center(a1, b1, c1, p1);
500  Center(a2, b2, c2, p2);
501  return sqrt(vtkMath::Distance2BetweenPoints(p1, p2));
502 }
503 
504 // -----------------------------------------------------------------------------
505 /// Compute distance between two triangles
506 inline double Triangle
507 ::DistanceBetweenCorners(const double a1[3], const double b1[3], const double c1[3],
508  const double a2[3], const double b2[3], const double c2[3],
509  double *p1, double *p2)
510 {
511  double d, dmin = vtkMath::Distance2BetweenPoints(a1, a2);
512  const double *x1 = a1, *x2 = a2;
513 
514  d = vtkMath::Distance2BetweenPoints(a1, b2);
515  if (d < dmin) dmin = d, x1 = a1, x2 = b2;
516 
517  d = vtkMath::Distance2BetweenPoints(a1, c2);
518  if (d < dmin) dmin = d, x1 = a1, x2 = c2;
519 
520  d = vtkMath::Distance2BetweenPoints(b1, a2);
521  if (d < dmin) dmin = d, x1 = b1, x2 = a2;
522 
523  d = vtkMath::Distance2BetweenPoints(b1, b2);
524  if (d < dmin) dmin = d, x1 = b1, x2 = b2;
525 
526  d = vtkMath::Distance2BetweenPoints(b1, c2);
527  if (d < dmin) dmin = d, x1 = b1, x2 = c2;
528 
529  d = vtkMath::Distance2BetweenPoints(c1, a2);
530  if (d < dmin) dmin = d, x1 = c1, x2 = a2;
531 
532  d = vtkMath::Distance2BetweenPoints(c1, b2);
533  if (d < dmin) dmin = d, x1 = c1, x2 = b2;
534 
535  d = vtkMath::Distance2BetweenPoints(c1, c2);
536  if (d < dmin) dmin = d, x1 = c1, x2 = c2;
537 
538  if (p1) memcpy(p1, x1, 3 * sizeof(double));
539  if (p2) memcpy(p2, x2, 3 * sizeof(double));
540  return sqrt(dmin);
541 }
542 
543 // -----------------------------------------------------------------------------
544 /// Compute distance between two triangles
545 inline double Triangle
546 ::DistanceBetweenTriangles(const double a1[3], const double b1[3], const double c1[3],
547  const double a2[3], const double b2[3], const double c2[3],
548  double *p1, double *p2)
549 {
550  double n1[3], n2[3];
551  Normal(a1, b1, c1, n1);
552  Normal(a2, b2, c2, n2);
553  return DistanceBetweenTriangles(a1, b1, c1, n1, a2, b2, c2, n2, p1, p2);
554 }
555 
556 
557 } // namespace mirtk
558 
559 #endif // MIRTK_Triangle_H
static double Cotangent(double a[3], double b[3], double c[3])
Definition: Triangle.h:374
static double Area(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:312
static double DoubleArea2D(const double a[2], const double b[2], const double c[2])
Definition: Triangle.h:330
static double MinAngle(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:357
static Matrix3x3 NormalDirectionJacobian(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:389
static double Area2D(const double a[2], const double b[2], const double c[2])
Definition: Triangle.h:336
static Matrix3x3 NormalJacobian(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:467
static bool TriangleTriangleIntersection(const double a1[3], const double b1[3], const double c1[3], const double a2[3], const double b2[3], const double c2[3])
Tests whether two triangles intersect each other.
static void NormalDirection(const double a[3], const double b[3], const double c[3], double n[3])
Definition: Triangle.h:281
static double DistanceBetweenCorners(const double a1[3], const double b1[3], const double c1[3], const double a2[3], const double b2[3], const double c2[3], double *p1, double *p2)
Compute distance between closest corner points of two triangles.
Definition: Triangle.h:507
Definition: IOConfig.h:41
static double DoubleArea(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:304
static double DoubleSignedArea2D(const double a[2], const double b[2], const double c[2])
Definition: Triangle.h:318
static Vector3 AreaGradient(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:483
static double SignedArea2D(const double a[2], const double b[2], const double c[2])
Definition: Triangle.h:324
static void Angles(const double a[3], const double b[3], const double c[3], double angle[3])
Definition: Triangle.h:346
static double BoundingSphereRadius(const double a[3], const double b[3], const double c[3], double *center=nullptr)
Definition: Triangle.h:266
static double DistanceBetweenTriangles(const double a1[3], const double b1[3], const double c1[3], const double n1[3], const double a2[3], const double b2[3], const double c2[3], const double n2[3], double *p1, double *p2)
Compute distance between closest points of two triangles.
static double DistanceBetweenCenters(const double a1[3], const double b1[3], const double c1[3], const double a2[3], const double b2[3], const double c2[3], double *p1, double *p2)
Compute distance between triangle center points.
Definition: Triangle.h:495
static double MaxAngle(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:365
static void Center(const double a[3], const double b[3], const double c[3], double center[3])
Definition: Triangle.h:258
static void Normal(const double a[3], const double b[3], const double c[3], double n[3])
Definition: Triangle.h:290
static Vector3 DoubleAreaGradient(const double a[3], const double b[3], const double c[3])
Definition: Triangle.h:474