~centralelyon2010/inkscape/imagelinks2

4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
1
#ifndef SEEN_TRANSF_MAT_3x4_H
2
#define SEEN_TRANSF_MAT_3x4_H
3
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
 */
14
15
#include "proj_pt.h"
16
#include "axis-manip.h"
17
18
namespace Proj {
19
20
class TransfMat3x4 {
21
public:
22
    TransfMat3x4();
23
    TransfMat3x4(Pt2 vp_x, Pt2 vp_y, Pt2 vp_z, Pt2 origin);
24
    TransfMat3x4(TransfMat3x4 const &rhs);
25
    Pt2 column (Proj::Axis axis) const;
26
    Pt2 image (Pt3 const &point);
6837 by cilix42
More NR::Point ==> Geom::Point
27
    Pt3 preimage (Geom::Point const &pt, double coord = 0, Axis = Z);
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
28
    void set_image_pt (Proj::Axis axis, Proj::Pt2 const &pt);
29
    void toggle_finite (Proj::Axis axis);
30
    double get_infinite_angle (Proj::Axis axis) {
31
        if (has_finite_image(axis)) {
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
32
            return Geom::infinity();
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
33
        }
34
        Pt2 vp(column(axis));
6837 by cilix42
More NR::Point ==> Geom::Point
35
        return Geom::atan2(Geom::Point(vp[0], vp[1])) * 180.0/M_PI;
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
36
    }
37
    void set_infinite_direction (Proj::Axis axis, double angle) { // angle is in degrees
38
        g_return_if_fail(tmat[2][axis] == 0); // don't set directions for finite VPs
39
40
        double a = angle * M_PI/180;
6837 by cilix42
More NR::Point ==> Geom::Point
41
        Geom::Point pt(tmat[0][axis], tmat[1][axis]);
42
        double rad = Geom::L2(pt);
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
43
        set_image_pt(axis, Proj::Pt2(cos (a) * rad, sin (a) * rad, 0.0));
44
    }
45
    inline bool has_finite_image (Proj::Axis axis) { return (tmat[2][axis] != 0.0); }
46
47
    gchar * pt_to_str (Proj::Axis axis);
48
49
    bool operator==(const TransfMat3x4 &rhs) const;
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
50
    TransfMat3x4 operator*(Geom::Affine const &A) const;
51
    TransfMat3x4 &operator*=(Geom::Affine const &A);
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
52
53
    void print() const;
54
5312 by cilix42
Forgot adding files during last commit
55
    void copy_tmat(double rhs[3][4]);
56
4224 by cilix42
Fundamentally reworked version of the 3D box tool (among many other things, this fixes bugs #168900 and #168868). See mailing list for details. Sorry for this single large commit but it was unfeasible to keep the history.
57
private:
58
    // FIXME: Is changing a single column allowed when a projective coordinate system is specified!?!?!
59
    void normalize_column (Proj::Axis axis);
60
    inline void set_column (Proj::Axis axis, Proj::Pt2 pt) {
61
        tmat[0][axis] = pt[0];
62
        tmat[1][axis] = pt[1];
63
        tmat[2][axis] = pt[2];
64
    }
65
    double tmat[3][4];
66
};
67
68
} // namespace Proj
69
70
#endif /* __TRANSF_MAT_3x4_H__ */
71
72
/*
73
  Local Variables:
74
  mode:c++
75
  c-file-style:"stroustrup"
76
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
77
  indent-tabs-mode:nil
78
  fill-column:99
79
  End:
80
*/
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
81
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :