1 /*
2 * Vanishing point for 3D perspectives
3 *
4 * Authors:
5 * Maximilian Albert <Anhalter42@gmx.de>
6 *
7 * Copyright (C) 2007 authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef SEEN_VANISHING_POINT_H
13 #define SEEN_VANISHING_POINT_H
15 #include "libnr/nr-point.h"
16 #include "line-geometry.h"
18 namespace Box3D {
20 enum VPState {
21 VP_FINITE = 0, // perspective lines meet in the VP
22 VP_INFINITE // perspective lines are parallel
23 };
25 // The X-/Y-/Z-axis corresponds to the first/second/third digit
26 // in binary representation, respectively.
27 enum Axis {
28 X = 1,
29 Y = 2,
30 Z = 4,
31 NONE = 0
32 };
35 /** Given two axis directions out of {X, Y, Z}, returns the remaining one */
36 inline Box3D::Axis third_axis_direction (Box3D::Axis dir1, Box3D::Axis dir2) {
37 return (Box3D::Axis) ((dir1 + dir2) ^ 0x7);
38 }
41 // FIXME: Store the Axis of the VP inside the class
42 class VanishingPoint : public NR::Point {
43 public:
44 inline VanishingPoint() : NR::Point() {};
45 /***
46 inline VanishingPoint(NR::Point const &pt, NR::Point const &ref = NR::Point(0,0))
47 : NR::Point (pt),
48 ref_pt (ref),
49 v_dir (pt[NR::X] - ref[NR::X], pt[NR::Y] - ref[NR::Y]) {}
50 inline VanishingPoint(NR::Coord x, NR::Coord y, NR::Point const &ref = NR::Point(0,0))
51 : NR::Point (x, y),
52 ref_pt (ref),
53 v_dir (x - ref[NR::X], y - ref[NR::Y]) {}
54 ***/
55 VanishingPoint(NR::Point const &pt, NR::Point const &inf_dir, VPState st);
56 VanishingPoint(NR::Point const &pt);
57 VanishingPoint(NR::Point const &dir, VPState const state);
58 VanishingPoint(NR::Point const &pt, NR::Point const &direction);
59 VanishingPoint(NR::Coord x, NR::Coord y);
60 VanishingPoint(NR::Coord x, NR::Coord y, VPState const state);
61 VanishingPoint(NR::Coord x, NR::Coord y, NR::Coord dir_x, NR::Coord dir_y);
62 VanishingPoint(VanishingPoint const &rhs);
64 bool is_finite();
65 VPState toggle_parallel();
66 void draw(Box3D::Axis const axis); // Draws a point on the canvas if state == VP_FINITE
67 //inline VPState state() { return state; }
69 VPState state;
70 //NR::Point ref_pt; // point of reference to compute the direction of parallel lines
71 NR::Point v_dir; // direction of perslective lines if the VP has state == VP_INFINITE
73 private:
74 };
77 } // namespace Box3D
80 /** A function to print out the VanishingPoint (prints the coordinates) **/
81 /***
82 inline std::ostream &operator<< (std::ostream &out_file, const VanishingPoint &vp) {
83 out_file << vp;
84 return out_file;
85 }
86 ***/
89 #endif /* !SEEN_VANISHING_POINT_H */
91 /*
92 Local Variables:
93 mode:c++
94 c-file-style:"stroustrup"
95 c-file-offsets:((innamespace . 0)(inline-open . 0))
96 indent-tabs-mode:nil
97 fill-column:99
98 End:
99 */
100 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :