source: GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/SimpleTri.cpp @ 3234

Revision 3234, 798 bytes checked in by mattausch, 16 years ago (diff)

visibility solution loader for jiris preprocessor
worked on poisson disc sampling

Line 
1#include "SimpleTri.h"
2
3
4using namespace std;
5
6
7SimpleTri::SimpleTri(const SimpleVec &a, const SimpleVec &b, const SimpleVec &c)
8{
9        Init(a, b, c);
10}
11
12
13void SimpleTri::Init(const SimpleVec &a, const SimpleVec &b, const SimpleVec &c)
14{
15        mVertices[0] = a;
16        mVertices[1] = b;
17        mVertices[2] = c;
18}
19
20
21SimpleVec SimpleTri::GetNormal() const
22{
23        const SimpleVec v1 = mVertices[0] - mVertices[1];
24        const SimpleVec v2 = mVertices[2] - mVertices[1];
25
26        return Normalize(CrossProd(v2, v1));
27}
28
29
30SimpleVec SimpleTri::GetWorldCenter() const
31{
32        return (mVertices[0] + mVertices[1] + mVertices[2]) / 3.0f;
33}
34
35
36float SimpleTri::GetArea() const
37{
38        SimpleVec v1 = mVertices[0] - mVertices[1], v2=mVertices[2] - mVertices[1];
39        return 0.5f * Magnitude(CrossProd(v2, v1));
40}
41
Note: See TracBrowser for help on using the repository browser.