GteTriangle.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
10 #include <Mathematics/GteVector.h>
11 
12 // The triangle is represented as an array of three vertices. The dimension
13 // N must be 2 or larger.
14 
15 namespace gte
16 {
17 
18 template <int N, typename Real>
19 class Triangle
20 {
21 public:
22  // Construction and destruction. The default constructor sets the
23  // vertices to (0,..,0), (1,0,...,0), and (0,1,0,...,0).
24  Triangle();
26  Vector<N, Real> const& v2);
27  Triangle(std::array<Vector<N, Real>, 3> const& inV);
28 
29  // Public member access.
30  std::array<Vector<N, Real>, 3> v;
31 
32 public:
33  // Comparisons to support sorted containers.
34  bool operator==(Triangle const& triangle) const;
35  bool operator!=(Triangle const& triangle) const;
36  bool operator< (Triangle const& triangle) const;
37  bool operator<=(Triangle const& triangle) const;
38  bool operator> (Triangle const& triangle) const;
39  bool operator>=(Triangle const& triangle) const;
40 };
41 
42 // Template aliases for convenience.
43 template <typename Real>
45 
46 template <typename Real>
48 
49 
50 template <int N, typename Real>
52 {
53  v[0].MakeZero();
54  v[1].MakeUnit(0);
55  v[2].MakeUnit(1);
56 }
57 
58 template <int N, typename Real>
60  Vector<N, Real> const& v1, Vector<N, Real> const& v2)
61 {
62  v[0] = v0;
63  v[1] = v1;
64  v[2] = v2;
65 }
66 
67 template <int N, typename Real>
69  :
70  v(inV)
71 {
72 }
73 
74 template <int N, typename Real>
75 bool Triangle<N, Real>::operator==(Triangle const& triangle) const
76 {
77  return v == triangle.v;
78 }
79 
80 template <int N, typename Real>
81 bool Triangle<N, Real>::operator!=(Triangle const& triangle) const
82 {
83  return !operator==(triangle);
84 }
85 
86 template <int N, typename Real>
87 bool Triangle<N, Real>::operator<(Triangle const& triangle) const
88 {
89  return v < triangle.v;
90 }
91 
92 template <int N, typename Real>
93 bool Triangle<N, Real>::operator<=(Triangle const& triangle) const
94 {
95  return operator<(triangle) || operator==(triangle);
96 }
97 
98 template <int N, typename Real>
99 bool Triangle<N, Real>::operator>(Triangle const& triangle) const
100 {
101  return !operator<=(triangle);
102 }
103 
104 template <int N, typename Real>
105 bool Triangle<N, Real>::operator>=(Triangle const& triangle) const
106 {
107  return !operator<(triangle);
108 }
109 
110 
111 }
bool operator<=(Triangle const &triangle) const
Definition: GteTriangle.h:93
bool operator==(Triangle const &triangle) const
Definition: GteTriangle.h:75
GLfloat GLfloat v1
Definition: glcorearb.h:812
bool operator<(Triangle const &triangle) const
Definition: GteTriangle.h:87
GLfloat v0
Definition: glcorearb.h:811
GLenum array
Definition: glext.h:6669
const GLdouble * v
Definition: glcorearb.h:832
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:813
bool operator!=(Triangle const &triangle) const
Definition: GteTriangle.h:81
bool operator>(Triangle const &triangle) const
Definition: GteTriangle.h:99
std::array< Vector< N, Real >, 3 > v
Definition: GteTriangle.h:30
bool operator>=(Triangle const &triangle) const
Definition: GteTriangle.h:105


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01