diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmath/llplane.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmath/llplane.h')
-rw-r--r-- | linden/indra/llmath/llplane.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/linden/indra/llmath/llplane.h b/linden/indra/llmath/llplane.h new file mode 100644 index 0000000..44721f3 --- /dev/null +++ b/linden/indra/llmath/llplane.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /** | ||
2 | * @file llplane.h | ||
3 | * | ||
4 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #ifndef LL_LLPLANE_H | ||
28 | #define LL_LLPLANE_H | ||
29 | |||
30 | #include "v3math.h" | ||
31 | #include "v4math.h" | ||
32 | |||
33 | // A simple way to specify a plane is to give its normal, | ||
34 | // and it's nearest approach to the origin. | ||
35 | // | ||
36 | // Given the equation for a plane : A*x + B*y + C*z + D = 0 | ||
37 | // The plane normal = [A, B, C] | ||
38 | // The closest approach = D / sqrt(A*A + B*B + C*C) | ||
39 | |||
40 | class LLPlane : public LLVector4 | ||
41 | { | ||
42 | public: | ||
43 | LLPlane() {}; // no default constructor | ||
44 | LLPlane(const LLVector3 &p0, F32 d) { setVec(p0, d); } | ||
45 | LLPlane(const LLVector3 &p0, const LLVector3 &n) { setVec(p0, n); } | ||
46 | void setVec(const LLVector3 &p0, F32 d) { LLVector4::setVec(p0[0], p0[1], p0[2], d); } | ||
47 | void setVec(const LLVector3 &p0, const LLVector3 &n) | ||
48 | { | ||
49 | F32 d = -(p0 * n); | ||
50 | setVec(n, d); | ||
51 | } | ||
52 | void setVec(const LLVector3 &p0, const LLVector3 &p1, const LLVector3 &p2) | ||
53 | { | ||
54 | LLVector3 u, v, w; | ||
55 | u = p1 - p0; | ||
56 | v = p2 - p0; | ||
57 | w = u % v; | ||
58 | w.normVec(); | ||
59 | F32 d = -(w * p0); | ||
60 | setVec(w, d); | ||
61 | } | ||
62 | LLPlane& operator=(const LLVector4& v2) { LLVector4::setVec(v2[0],v2[1],v2[2],v2[3]); return *this;} | ||
63 | F32 dist(const LLVector3 &v2) const { return mV[0]*v2[0] + mV[1]*v2[1] + mV[2]*v2[2] + mV[3]; } | ||
64 | }; | ||
65 | |||
66 | |||
67 | |||
68 | #endif // LL_LLPLANE_H | ||