JNR
laTriangle3.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_TRIANGLE3_H
30 #define M_TRIANGLE3_H
31 
33 
34 
37 //
39 
41 {
42 public:
43 
44  laPoint3 p[3];
46 
47  //CBox box; // bounding box
48 
49  // Constructors and destructor
50  //
51  laTriangle3() {}
52 
53  laTriangle3(laPoint3 aa, laPoint3 ab, laPoint3 ac){
54  setVertices(aa,ab,ac);
55  }
56 
57  void setVertices(laPoint3 &a, laPoint3 &b, laPoint3 &c){
58  p[0]=a; p[1]=b; p[2]=c;
59  updatePlane();
60  //updateBB();
61  }
62 
63  virtual ~laTriangle3() {}
64 
65  // Precompute parameters
66  //
67  void updatePlane(){
68  pn.build(p[0], p[1], p[2]);
69  }
70 
71  //void updateBB();
72 
73  void getPerimeterLines(laLine3 *ar){
74  ar[0].build_2pt(p[0], p[1]);
75  ar[1].build_2pt(p[1], p[2]);
76  ar[2].build_2pt(p[2], p[0]);
77  }
78 
79  // Find a point on the perimeter of the triangle,
80  // nearest to the specified point
81  //laPoint3 projectOnPerimeter(laPoint3 p);
82 
83  // Check if a point is inside the folume defined by the 3 planes,
84  // originating at the edges of the triangle
85  BOOL isInsideVolume(laPoint3 &pt);
86 
87  // Collisiton detection and repsonse
88  //
89  // t - triangle to collide with
90  // vt - velocity; outputs modified velocity
91  // return value - modofied velocity after collision detection and response
92  //
93  laPoint3 collide(laTriangle3 &t, laPoint3 &vt);
94 
95  // ?
96  void wrapPoint(laPoint3 &p);
97 
98  //laPoint3 GetSideDistance(laPoint3 &p, unsigned nside, double &dv);
99  //void BuildWarpedRect(laTriangle3 *arRect, laPoint3 &ptPivot, double dwSideLen);
100  //void Save(ofstream &f);
101  //bool InsideBox(CBox &b);
102  //void Validate();
103 
104 };
106 #endif
3D line segment
Definition: laLine3.h:40
void build(laPoint3 &a, laPoint3 &b, laPoint3 &c)
Build laPlane3 from three points ( laPoint3 objects )
Definition: laPlane3.h:55
void build_2pt(laPoint3 &a, laPoint3 &b)
Build from two end-points.
Definition: laLine3.h:55
laPoint3 p[3]
Vertices of the triangle.
Definition: laTriangle3.h:44
laPlane3 pn
Parametric 3D plane.
Definition: laTriangle3.h:45
3D plane
Definition: laPlane3.h:39
3D triangle face NOTE: This class has not been tested (NT)
Definition: laTriangle3.h:40