RigsofRods
Soft-body Physics Simulation
source
main
physics
collision
Triangle.h
Go to the documentation of this file.
1
/*
2
This source file is part of Rigs of Rods
3
Copyright 2016 Fabian Killus
4
5
For more information, see http://www.rigsofrods.org/
6
7
Rigs of Rods is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License version 3, as
9
published by the Free Software Foundation.
10
11
Rigs of Rods is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <OgreVector3.h>
23
26
29
35
class
Triangle
36
{
37
public
:
39
explicit
Triangle
(
const
Ogre::Vector3&
a
,
const
Ogre::Vector3&
b
,
const
Ogre::Vector3&
c
)
40
:
a
{
a
},
b
{
b
},
c
{
c
},
u
{
a
-
c
},
v
{
b
-
c
},
m_initialized
{
false
}
41
{
42
}
43
48
Ogre::Vector3
normal
()
const
49
{
50
if
(!
m_initialized
)
51
{
52
m_normal
=
u
.crossProduct(
v
);
53
m_normal
.normalise();
54
m_initialized
=
true
;
55
}
56
return
m_normal
;
57
}
58
59
const
Ogre::Vector3
a
,
60
b
,
61
c
;
62
63
const
Ogre::Vector3
u
,
64
v
;
65
66
private
:
67
mutable
bool
m_initialized
;
68
mutable
Ogre::Vector3
m_normal
;
69
};
70
Triangle
Represents a triangle in three-dimensional space.
Definition:
Triangle.h:35
Triangle::Triangle
Triangle(const Ogre::Vector3 &a, const Ogre::Vector3 &b, const Ogre::Vector3 &c)
Construct triangle from three given vertices.
Definition:
Triangle.h:39
Triangle::m_normal
Ogre::Vector3 m_normal
Cached normal vector.
Definition:
Triangle.h:68
Triangle::normal
Ogre::Vector3 normal() const
Return normal vector of the triangle.
Definition:
Triangle.h:48
Triangle::v
const Ogre::Vector3 v
Span vector v.
Definition:
Triangle.h:64
Triangle::u
const Ogre::Vector3 u
Span vector u.
Definition:
Triangle.h:63
Triangle::c
const Ogre::Vector3 c
Vertex c.
Definition:
Triangle.h:61
Triangle::m_initialized
bool m_initialized
Definition:
Triangle.h:67
Triangle::a
const Ogre::Vector3 a
Vertex a.
Definition:
Triangle.h:59
Triangle::b
const Ogre::Vector3 b
Vertex b.
Definition:
Triangle.h:60
Generated by
1.8.17