Last change
on this file since 4587 was
3502,
checked in by ldelgass, 12 years ago
|
Add basic VTK structured points reader to nanovis, update copyright dates.
|
-
Property svn:eol-style set to
native
|
File size:
1.6 KB
|
Rev | Line | |
---|
[2798] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
[1028] | 2 | /* |
---|
| 3 | * ---------------------------------------------------------------------- |
---|
| 4 | * Plane.cpp: plane class |
---|
| 5 | * |
---|
| 6 | * ====================================================================== |
---|
| 7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
| 8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
| 9 | * |
---|
[3502] | 10 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
[1028] | 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> |
---|
[2822] | 17 | |
---|
[1028] | 18 | #include "Plane.h" |
---|
| 19 | |
---|
[3492] | 20 | using namespace nv; |
---|
| 21 | |
---|
[2822] | 22 | Plane::Plane(float _a, float _b, float _c, float _d) : |
---|
| 23 | a(_a), |
---|
| 24 | b(_b), |
---|
| 25 | c(_c), |
---|
| 26 | d(_d) |
---|
| 27 | { |
---|
[1028] | 28 | assert(a != 0 || b != 0 || c != 0); |
---|
| 29 | } |
---|
| 30 | |
---|
[2822] | 31 | Plane::Plane(float coeffs[4]) |
---|
| 32 | { |
---|
[1028] | 33 | a = coeffs[0]; |
---|
| 34 | b = coeffs[1]; |
---|
| 35 | c = coeffs[2]; |
---|
| 36 | d = coeffs[3]; |
---|
| 37 | |
---|
| 38 | assert(a != 0 || b != 0 || c != 0); |
---|
| 39 | } |
---|
| 40 | |
---|
[2822] | 41 | void |
---|
[3492] | 42 | Plane::transform(const vrmath::Matrix4x4d& mat) |
---|
[2822] | 43 | { |
---|
[3492] | 44 | vrmath::Vector4f coeffs(a, b, c, d); |
---|
[1028] | 45 | |
---|
[3492] | 46 | vrmath::Matrix4x4d inv = mat.inverse(); |
---|
| 47 | vrmath::Vector4f new_coeffs = inv.preMultiplyRowVector(coeffs); |
---|
[1028] | 48 | a = new_coeffs.x; |
---|
| 49 | b = new_coeffs.y; |
---|
| 50 | c = new_coeffs.z; |
---|
| 51 | d = new_coeffs.w; |
---|
| 52 | } |
---|
| 53 | |
---|
[2822] | 54 | void |
---|
[3492] | 55 | Plane::getPoint(vrmath::Vector3f& point) |
---|
[2822] | 56 | { |
---|
| 57 | if (a != 0) { |
---|
| 58 | point.x = -d/a; |
---|
| 59 | point.y = 0; |
---|
| 60 | point.z = 0; |
---|
[1028] | 61 | } else if (b != 0) { |
---|
[2822] | 62 | point.y = -d/b; |
---|
| 63 | point.x = 0; |
---|
| 64 | point.z = 0; |
---|
[1028] | 65 | } else if (c != 0) { |
---|
[2822] | 66 | point.z = -d /c; |
---|
| 67 | point.y = 0; |
---|
| 68 | point.x = 0; |
---|
| 69 | } else { |
---|
| 70 | assert(false); |
---|
[1028] | 71 | } |
---|
| 72 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.