Overture  Version 25
TriangleClass.h
Go to the documentation of this file.
1 #ifndef TRIANGLE_H
2 #define TRIANGLE_H
3 
4 #include "Mapping.h"
5 
6 class Triangle
7 {
8  public:
9  Triangle();
10  Triangle( const real x1[3], const real x2[3], const real x3[3] );
11  Triangle( const RealArray & x1, const RealArray & x2, const RealArray & x3 );
12  Triangle( const realArray & grid,
13  const int & i1,
14  const int & i2,
15  const int & i3,
16  const int & choice=0,
17  const int & axis=axis3 );
18  ~Triangle();
19 
20  real area() const; // return the area of the triangle
21  void setVertices( const real x1_[3], const real x2_[3], const real x3_[3] );
22  void setVertices( const RealArray & x1, const RealArray & x2, const RealArray & x3 );
23  void setVertices(const realArray & grid,
24  const int & i1,
25  const int & i2,
26  const int & i3,
27  const int & choice=0,
28  const int & axis=axis3 );
29  #ifdef USE_PPP
30  void setVertices(const RealArray & grid,
31  const int & i1,
32  const int & i2,
33  const int & i3,
34  const int & choice=0,
35  const int & axis=axis3 );
36  #endif
37  // does this triangle intersect another? return segment of intersection
38  bool intersects(Triangle & triangle, real xi1[3], real xi2[3] ) const;
39  bool intersects(Triangle & triangle, RealArray & xi1, RealArray & xi2 ) const;
40 
41  // does a ray from the point x to y=infinity cross the triangle?
42  bool intersects(real x[3], real xi[3] ) const;
43  bool intersects(RealArray & x, RealArray & xi ) const;
44 
45  // does a ray from the point x in the direction b1 cross the triangle?
46  // The vectors b0,b1,b3 form an orthononmal basis
47  bool intersects(real x[3], real xi[3], real b0[3], real b1[3], real b2[3] ) const;
48  bool intersects(RealArray & x, RealArray & xi, real b0[3], real b1[3], real b2[3] ) const;
49 
50  int getRelativeCoordinates( const real x[3], real & alpha1, real & alpha2, const bool & shouldBeInside=TRUE ) const;
51 
52  void display(const aString & label=blankString) const;
53 
54  double tetrahedralVolume(const real a[], const real b[], const real c[], const real d[]) const;
55 
56  real x1[3], x2[3], x3[3]; // three vertices
57  real normal[4]; // holds normal plus constant for eqn of the plane, n.x+c=0
58  void computeNormal();
59 
60 };
61 
62 #endif