Last change
on this file since 2822 was
2822,
checked in by ldelgass, 13 years ago
|
Const correctness fixes, pass vector/matrix objects by reference, various
formatting and style cleanups, don't spam syslog and uncomment openlog() call.
Still needs to be compiled with -DWANT_TRACE to get tracing, but now trace
output will be output to file in /tmp.
|
-
Property svn:eol-style set to
native
|
File size:
1.5 KB
|
Line | |
---|
1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * Plane.cpp: plane class |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | #include <assert.h> |
---|
17 | |
---|
18 | #include "Plane.h" |
---|
19 | |
---|
20 | Plane::Plane(float _a, float _b, float _c, float _d) : |
---|
21 | a(_a), |
---|
22 | b(_b), |
---|
23 | c(_c), |
---|
24 | d(_d) |
---|
25 | { |
---|
26 | assert(a != 0 || b != 0 || c != 0); |
---|
27 | } |
---|
28 | |
---|
29 | Plane::Plane(float coeffs[4]) |
---|
30 | { |
---|
31 | a = coeffs[0]; |
---|
32 | b = coeffs[1]; |
---|
33 | c = coeffs[2]; |
---|
34 | d = coeffs[3]; |
---|
35 | |
---|
36 | assert(a != 0 || b != 0 || c != 0); |
---|
37 | } |
---|
38 | |
---|
39 | void |
---|
40 | Plane::transform(const Mat4x4& mat) |
---|
41 | { |
---|
42 | Vector4 coeffs(a, b, c, d); |
---|
43 | |
---|
44 | Mat4x4 inv = mat.inverse(); |
---|
45 | Vector4 new_coeffs = inv.multiply_row_vector(coeffs); |
---|
46 | a = new_coeffs.x; |
---|
47 | b = new_coeffs.y; |
---|
48 | c = new_coeffs.z; |
---|
49 | d = new_coeffs.w; |
---|
50 | } |
---|
51 | |
---|
52 | void |
---|
53 | Plane::get_point(Vector3& point) |
---|
54 | { |
---|
55 | if (a != 0) { |
---|
56 | point.x = -d/a; |
---|
57 | point.y = 0; |
---|
58 | point.z = 0; |
---|
59 | } else if (b != 0) { |
---|
60 | point.y = -d/b; |
---|
61 | point.x = 0; |
---|
62 | point.z = 0; |
---|
63 | } else if (c != 0) { |
---|
64 | point.z = -d /c; |
---|
65 | point.y = 0; |
---|
66 | point.x = 0; |
---|
67 | } else { |
---|
68 | assert(false); |
---|
69 | } |
---|
70 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.