1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * Plane.h: 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 | #ifndef _PLANE_H_ |
---|
17 | #define _PLANE_H_ |
---|
18 | |
---|
19 | #include "Vector3.h" |
---|
20 | #include "Mat4x4.h" |
---|
21 | |
---|
22 | class Plane { |
---|
23 | float a, b, c, d; |
---|
24 | public: |
---|
25 | |
---|
26 | Plane(float a, float b, float c, float d); |
---|
27 | Plane(float coeffs[4]); |
---|
28 | Plane(void) { |
---|
29 | /*empty*/ |
---|
30 | }; |
---|
31 | |
---|
32 | void get_point(Vector3 &point); |
---|
33 | //bool clips(float point[3]) const { return !retains(point); } |
---|
34 | |
---|
35 | void transform(Mat4x4 mat); |
---|
36 | void transform(float *m) { |
---|
37 | Mat4x4 mat(m); |
---|
38 | transform(mat); |
---|
39 | } |
---|
40 | bool retains(Vector3 point) { |
---|
41 | return ((a*point.x + b*point.y + c*point.z + d) >= 0); |
---|
42 | } |
---|
43 | Vector4 get_coeffs(void) { |
---|
44 | return Vector4(a, b, c, d); |
---|
45 | } |
---|
46 | void set_coeffs(float a_val, float b_val, float c_val, float d_val) { |
---|
47 | a = a_val, b = b_val, c = c_val, d = d_val; |
---|
48 | } |
---|
49 | void get_normal(Vector3 &normal) { |
---|
50 | normal.x = a; |
---|
51 | normal.y = b; |
---|
52 | normal.z = c; |
---|
53 | } |
---|
54 | }; |
---|
55 | |
---|
56 | |
---|
57 | #endif |
---|