Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/mesher/triangleTetIntersection.h

raw symbols SCIP
1 /*************************************************************************
2 * *
3 * Vega FEM Simulation Library Version 3.1 *
4 * *
5 * "mesher" library , Copyright (C) 2016 USC *
6 * All rights reserved. *
7 * *
8 * Code authors: Danyong Zhao, Yijing Li, Jernej Barbic *
9 * http://www.jernejbarbic.com/code *
10 * *
11 * Funding: National Science Foundation *
12 * *
13 * This library is free software; you can redistribute it and/or *
14 * modify it under the terms of the BSD-style license that is *
15 * included with this library in the file LICENSE.txt *
16 * *
17 * This library is distributed in the hope that it will be useful, *
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
20 * LICENSE.TXT for more details. *
21 * *
22 *************************************************************************/
23
24 /*
25 Intersection between a tet and a triangle.
26 */
27
28 #ifndef _TRIANGLETETINTERSECTION_H_
29 #define _TRIANGLETETINTERSECTION_H_
30
31 #include "vec3d.h"
32
33 // This class computes whether a tetrahedron intersects a triangle, excluding just touching.
34 class TriangleTetIntersection
35 {
36 public:
37
38 // does the tetrahedron intersects the triangle, excluding just touching
39 static bool tetrahedronIntersectTriangle(const Vec3d & tet1, const Vec3d & tet2, const Vec3d & tet3, const Vec3d & tet4, const Vec3d & t1, const Vec3d & t2, const Vec3d & t3);
40
41 protected:
42 class Tetrahedron
43 {
44 protected:
45 // The positions of the four vertices
46 const Vec3d v0, v1, v2, v3;
47
48 // The normals of the four faces
49 Vec3d n0, n1, n2, n3;
50 // The positions of the four faces
51 double d0, d1, d2, d3;
52 public:
53 Tetrahedron(const Vec3d & v0, const Vec3d & v1, const Vec3d & v2, const Vec3d & v3);
54 // Whether a point is inside the tetrahedron, excluding on the tetrahedron
55 bool contains(const Vec3d & p);
56 };
57
58 class Triangle
59 {
60 protected:
61 // The positions of the three vertices
62 const Vec3d v0, v1, v2;
63 // The normal
64 Vec3d n;
65 // The position of the face
66 double d;
67 // The two base vectors of the face
68 Vec3d base1, base2;
69 public:
70 Triangle(const Vec3d & v0, const Vec3d & v1, const Vec3d & v2);
71 // Whether a point is inside the triangle, excluding on the triangle
72 bool contains(const Vec3d & p);
73 // Whether the segment starting from l0 and ending at l1 intersects the triangle, excluding just touching
74 bool intersect(const Vec3d & l0, const Vec3d & l1);
75 };
76
77 //compute the determinant of a 3x3 matrix defined by three vectors whose dimensions are all three
78 static inline double det(const Vec3d & a, const Vec3d & b, const Vec3d & c) { return dot(a, cross(b, c)); }
79
80 private:
81 TriangleTetIntersection();
82 };
83
84 #endif /* INTERSECTION_H_ */
85