1 #ifndef SEEN_TRANSF_MAT_3x4_H
2 #define SEEN_TRANSF_MAT_3x4_H
4 /*
5 * 3x4 transformation matrix to map points from projective 3-space into the projective plane
6 *
7 * Authors:
8 * Maximilian Albert <Anhalter42@gmx.de>
9 *
10 * Copyright (C) 2007 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "proj_pt.h"
16 #include "axis-manip.h"
17 #include "libnr/nr-point-fns.h"
19 namespace Proj {
21 class TransfMat3x4 {
22 public:
23 TransfMat3x4();
24 TransfMat3x4(Pt2 vp_x, Pt2 vp_y, Pt2 vp_z, Pt2 origin);
25 TransfMat3x4(TransfMat3x4 const &rhs);
26 Pt2 column (Proj::Axis axis) const;
27 Pt2 image (Pt3 const &point);
28 Pt3 preimage (NR::Point const &pt, double coord = 0, Axis = Z);
29 void set_image_pt (Proj::Axis axis, Proj::Pt2 const &pt);
30 void toggle_finite (Proj::Axis axis);
31 double get_infinite_angle (Proj::Axis axis) {
32 if (has_finite_image(axis)) {
33 return NR_HUGE;
34 }
35 Pt2 vp(column(axis));
36 return NR::atan2(NR::Point(vp[0], vp[1])) * 180.0/M_PI;
37 }
38 void set_infinite_direction (Proj::Axis axis, double angle) { // angle is in degrees
39 g_return_if_fail(tmat[2][axis] == 0); // don't set directions for finite VPs
41 double a = angle * M_PI/180;
42 NR::Point pt(tmat[0][axis], tmat[1][axis]);
43 double rad = NR::L2(pt);
44 set_image_pt(axis, Proj::Pt2(cos (a) * rad, sin (a) * rad, 0.0));
45 }
46 inline bool has_finite_image (Proj::Axis axis) { return (tmat[2][axis] != 0.0); }
48 gchar * pt_to_str (Proj::Axis axis);
50 bool operator==(const TransfMat3x4 &rhs) const;
51 TransfMat3x4 operator*(NR::Matrix const &A) const;
52 TransfMat3x4 &operator*=(NR::Matrix const &A);
54 void print() const;
56 private:
57 // FIXME: Is changing a single column allowed when a projective coordinate system is specified!?!?!
58 void normalize_column (Proj::Axis axis);
59 inline void set_column (Proj::Axis axis, Proj::Pt2 pt) {
60 tmat[0][axis] = pt[0];
61 tmat[1][axis] = pt[1];
62 tmat[2][axis] = pt[2];
63 }
64 double tmat[3][4];
65 };
67 } // namespace Proj
69 #endif /* __TRANSF_MAT_3x4_H__ */
71 /*
72 Local Variables:
73 mode:c++
74 c-file-style:"stroustrup"
75 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76 indent-tabs-mode:nil
77 fill-column:99
78 End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :