X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftransf_mat_3x4.cpp;h=533972e29dbff52b907695d43137d452cd1fa78a;hb=ec12cb48c1da4c3029b9e8c2eea263499d319599;hp=a624fb1636bb5ef7db1f20af4ce8c4838385f11c;hpb=4358ff6156766a315e38e72a5c3c83d6d5f7486b;p=inkscape.git diff --git a/src/transf_mat_3x4.cpp b/src/transf_mat_3x4.cpp index a624fb163..533972e29 100644 --- a/src/transf_mat_3x4.cpp +++ b/src/transf_mat_3x4.cpp @@ -13,9 +13,9 @@ #include "transf_mat_3x4.h" #include +#include <2geom/matrix.h> #include "svg/stringstream.h" #include "syseq.h" -#include "libnr/nr-matrix.h" #include "document.h" #include "inkscape.h" @@ -61,11 +61,11 @@ TransfMat3x4::image (Pt3 const &point) { } Pt3 -TransfMat3x4::preimage (NR::Point const &pt, double coord, Proj::Axis axis) { +TransfMat3x4::preimage (Geom::Point const &pt, double coord, Proj::Axis axis) { double x[4]; double v[3]; - v[0] = pt[NR::X]; - v[1] = pt[NR::Y]; + v[0] = pt[Geom::X]; + v[1] = pt[Geom::Y]; v[2] = 1.0; int index = (int) axis; @@ -93,10 +93,10 @@ void TransfMat3x4::toggle_finite (Proj::Axis axis) { g_return_if_fail (axis != Proj::W); if (has_finite_image(axis)) { - NR::Point dir (column(axis).affine()); - NR::Point origin (column(Proj::W).affine()); + Geom::Point dir (column(axis).affine()); + Geom::Point origin (column(Proj::W).affine()); dir -= origin; - set_column (axis, Proj::Pt2(dir[NR::X], dir[NR::Y], 0)); + set_column (axis, Proj::Pt2(dir[Geom::X], dir[Geom::Y], 0)); } else { Proj::Pt2 dir (column(axis)); Proj::Pt2 origin (column(Proj::W).affine()); @@ -115,6 +115,7 @@ TransfMat3x4::pt_to_str (Proj::Axis axis) { return g_strdup(os.str().c_str()); } +/* Check for equality (with a small tolerance epsilon) */ bool TransfMat3x4::operator==(const TransfMat3x4 &rhs) const { @@ -129,29 +130,16 @@ TransfMat3x4::operator==(const TransfMat3x4 &rhs) const return true; } -/* multiply a projective matrix by an affine matrix */ +/* Multiply a projective matrix by an affine matrix (by only multiplying the 'affine part' of the + * projective matrix) */ TransfMat3x4 -TransfMat3x4::operator*(NR::Matrix const &A) const { +TransfMat3x4::operator*(Geom::Matrix const &A) const { TransfMat3x4 ret; - // Is it safe to always use the currently active document? - double h = sp_document_height(inkscape_active_document()); - - /* - * Note: The strange multiplication involving the document height is due to the buggy - * intertwining of SVG and document coordinates. Essentially, what we do is first - * convert from "real-world" to SVG coordinates, then apply the transformation A - * (by multiplying with the NR::Matrix) and then convert back from SVG to real-world - * coordinates. Maybe there is even a more Inkscape-ish way to achieve this? - * Once Inkscape has gotton rid of the two different coordiate systems, we can change - * this function to an ordinary matrix multiplication. - */ for (int j = 0; j < 4; ++j) { - ret.tmat[0][j] = A[0]*tmat[0][j] + A[2]*(h*tmat[2][j] - tmat[1][j]) + A[4]*tmat[2][j]; - ret.tmat[1][j] = A[1]*tmat[0][j] + A[3]*(h*tmat[2][j] - tmat[1][j]) + A[5]*tmat[2][j]; + ret.tmat[0][j] = A[0]*tmat[0][j] + A[2]*tmat[1][j] + A[4]*tmat[2][j]; + ret.tmat[1][j] = A[1]*tmat[0][j] + A[3]*tmat[1][j] + A[5]*tmat[2][j]; ret.tmat[2][j] = tmat[2][j]; - - ret.tmat[1][j] = h*ret.tmat[2][j] - ret.tmat[1][j]; // switch back from SVG to desktop coordinates } return ret; @@ -160,11 +148,19 @@ TransfMat3x4::operator*(NR::Matrix const &A) const { // FIXME: Shouldn't rather operator* call operator*= for efficiency? (Because in operator*= // there is in principle no need to create a temporary object, which happens in the assignment) TransfMat3x4 & -TransfMat3x4::operator*=(NR::Matrix const &A) { +TransfMat3x4::operator*=(Geom::Matrix const &A) { *this = *this * A; return *this; } +void +TransfMat3x4::copy_tmat(double rhs[3][4]) { + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + rhs[i][j] = tmat[i][j]; + } + } +} void TransfMat3x4::print () const { @@ -197,4 +193,4 @@ TransfMat3x4::normalize_column (Proj::Axis axis) { fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :