GteCullingPlane.cpp
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 #include <GTEnginePCH.h>
10 using namespace gte;
11 
12 
14 {
15 }
16 
18  :
19  mTuple({ 0.0f, 0.0f, 0.0f, 0.0f })
20 {
21 }
22 
24  :
25  mTuple(plane.mTuple)
26 {
27 }
28 
30  :
31  mTuple({ N[0], N[1], N[2], c })
32 {
33 }
34 
35 CullingPlane::CullingPlane (float n0, float n1, float n2, float c)
36  :
37  mTuple({ n0, n1, n2, c })
38 {
39 }
40 
42  :
43  mTuple({ N[0], N[1], N[2], -Dot(N, P) })
44 {
45 }
46 
48  Vector4<float> const& P1, Vector4<float> const& P2)
49 {
50  Vector4<float> edge1 = P1 - P0;
51  Vector4<float> edge2 = P2 - P0;
52  Vector4<float> N = Cross(edge1, edge2);
53  mTuple[0] = N[0];
54  mTuple[1] = N[1];
55  mTuple[2] = N[2];
56  mTuple[3] = -Dot(N, P0);
57 }
58 
60 {
61  mTuple = plane.mTuple;
62  return *this;
63 }
64 
65 void CullingPlane::Set (Vector4<float> const& N, float c)
66 {
67  mTuple[0] = N[0];
68  mTuple[1] = N[1];
69  mTuple[2] = N[2];
70  mTuple[3] = c;
71 }
72 
73 void CullingPlane::Get (Vector4<float>& N, float& c) const
74 {
75  N[0] = mTuple[0];
76  N[1] = mTuple[1];
77  N[2] = mTuple[2];
78  c = mTuple[3];
79 }
80 
82 {
83  return Vector4<float>{ mTuple[0], mTuple[1], mTuple[2], 0.0f };
84 }
85 
87 {
88  return mTuple[3];
89 }
90 
92 {
93  float length = sqrt(mTuple[0]*mTuple[0] + mTuple[1]*mTuple[1] +
94  mTuple[2]*mTuple[2]);
95  mTuple /= length;
96  return length;
97 }
98 
100 {
101  float distance = Dot(mTuple, P);
102  return (distance > 0.0f ? +1 : (distance < 0.0f ? -1 : 0));
103 }
104 
106 {
107  return Dot(mTuple, P);
108 }
109 
GLsizei GLsizei GLfloat distance
Definition: glext.h:9704
void Set(Vector4< float > const &N, float c)
CullingPlane & operator=(CullingPlane const &plane)
const GLubyte * c
Definition: glext.h:11671
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Vector4< float > GetNormal() const
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:790
Vector4< float > mTuple
void Get(Vector4< float > &N, float &c) const
GLfloat f
Definition: glcorearb.h:1921
float GetConstant() const
float DistanceTo(Vector4< float > const &P) const
int WhichSide(Vector4< float > const &P) const


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59