source: trunk/packages/vizservers/nanovis/Plane.h @ 3452

Last change on this file since 3452 was 3362, checked in by ldelgass, 11 years ago

Merge nanovis2 branch to trunk

  • 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.h: plane class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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
22class Plane
23{
24public:
25    Plane(float a, float b, float c, float d);
26
27    Plane(float coeffs[4]);
28
29    Plane()
30    {}
31
32    void getPoint(Vector3& point);
33
34    //bool clips(float point[3]) const { return !retains(point); }
35
36    void transform(const Mat4x4& mat);
37
38    void transform(float *m)
39    {
40        Mat4x4 mat(m);
41        transform(mat);
42    }
43
44    bool retains(const Vector3& point) const
45    {
46        return ((a*point.x + b*point.y + c*point.z + d) >= 0);
47    }
48
49    Vector4 getCoeffs() const
50    {
51        return Vector4(a, b, c, d);
52    }
53
54    void setCoeffs(float a_val, float b_val, float c_val, float d_val)
55    {
56        a = a_val, b = b_val, c = c_val, d = d_val;
57    }
58
59    void getNormal(Vector3& normal) const
60    {
61        normal.x = a;
62        normal.y = b;
63        normal.z = c;
64    }
65
66private:
67    float a, b, c, d;
68};
69
70
71#endif
Note: See TracBrowser for help on using the repository browser.