summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b541bb)
raw | patch | inline | side by side (parent: 6b541bb)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 3 Jul 2007 18:32:33 +0000 (18:32 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 3 Jul 2007 18:32:33 +0000 (18:32 +0000) |
src/box3d-face.cpp | patch | blob | history | |
src/vanishing-point.h | patch | blob | history |
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 13e19d769a81bcd90edad7543e800aa5ef83a14a..8b3b5d96886a578428976c568b42aee636e81fea 100644 (file)
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
corners[2] = lr;
} else {
if (align_along_PL) {
- Box3D::PerspDir dir3;
- if (dir1 == Box3D::X && dir2 == Box3D::Z) dir3 = Box3D::Y;
- if (dir1 == Box3D::X && dir2 == Box3D::Y) dir3 = Box3D::Z;
- if (dir1 == Box3D::Z && dir2 == Box3D::X) dir3 = Box3D::Y;
- if (dir1 == Box3D::Z && dir2 == Box3D::Y) dir3 = Box3D::X;
- if (dir1 == Box3D::Y && dir2 == Box3D::X) dir3 = Box3D::Z;
- if (dir1 == Box3D::Y && dir2 == Box3D::Z) dir3 = Box3D::X;
+ Box3D::PerspDir dir3 = Box3D::third_axis_direction (dir1, dir2);
Box3D::Line line1(*SP3DBoxContext::current_perspective->get_vanishing_point(dir1), lr);
Box3D::Line line2(*pt_align, *SP3DBoxContext::current_perspective->get_vanishing_point(dir3));
corners[2] = *line1.intersect(line2);
diff --git a/src/vanishing-point.h b/src/vanishing-point.h
index 4770c74f1b74e7d00ada0853c1bbf3a984482816..de06002e4ddc47e188dc280d985e2468c04bdb63 100644 (file)
--- a/src/vanishing-point.h
+++ b/src/vanishing-point.h
VP_INFINITE // perspective lines are parallel
};
+// The X-/Y-/Z-axis corresponds to the first/second/third digit
+// in binary representation, respectively.
enum PerspDir {
- X,
- Y,
- Z,
- NONE
+ X = 1,
+ Y = 2,
+ Z = 4,
+ NONE = 0
};
+
+/** Given two axis directions out of {X, Y, Z}, returns the remaining one */
+inline Box3D::PerspDir third_axis_direction (Box3D::PerspDir dir1, Box3D::PerspDir dir2) {
+ return (Box3D::PerspDir) ((dir1 + dir2) ^ 0x7);
+}
+
+
// FIXME: Store the PerspDir of the VP inside the class
class VanishingPoint : public NR::Point {
public: