# source:trunk/packages/vizservers/nanovis/Plane.h@3502

Last change on this file since 3502 was 3502, checked in by ldelgass, 6 years ago

• Property svn:eol-style set to `native`
File size: 1.7 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-2013  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 <vrmath/Vector3f.h>
20#include <vrmath/Vector4f.h>
21#include <vrmath/Matrix4x4d.h>
22
23namespace nv {
24
25class Plane
26{
27public:
28    Plane(float a, float b, float c, float d);
29
30    Plane(float coeffs[4]);
31
32    Plane()
33    {}
34
35    void getPoint(vrmath::Vector3f& point);
36
37    //bool clips(float point[3]) const { return !retains(point); }
38
39    void transform(const vrmath::Matrix4x4d& mat);
40
41    void transform(float *m)
42    {
43        vrmath::Matrix4x4d mat;
44        mat.setFloat(m);
45        transform(mat);
46    }
47
48    bool retains(const vrmath::Vector3f& point) const
49    {
50        return ((a*point.x + b*point.y + c*point.z + d) >= 0);
51    }
52
53    vrmath::Vector4f getCoeffs() const
54    {
55        return vrmath::Vector4f(a, b, c, d);
56    }
57
58    void setCoeffs(float a_val, float b_val, float c_val, float d_val)
59    {
60        a = a_val, b = b_val, c = c_val, d = d_val;
61    }
62
63    void getNormal(vrmath::Vector3f& normal) const
64    {
65        normal.x = a;
66        normal.y = b;
67        normal.z = c;
68    }
69
70private:
71    float a, b, c, d;
72};
73
74}
75
76#endif
Note: See TracBrowser for help on using the repository browser.