1 #define __SP_DESKTOP_AFFINE_C__
3 /*
4 * Editable view and widget implementation
5 *
6 * Author:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 *
9 * Copyright (C) 1999-2002 Lauris Kaplinski
10 * Copyright (C) 2000-2001 Ximian, Inc.
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "desktop.h"
16 #include "document.h"
17 #include "sp-root.h"
18 #include "libnr/nr-matrix-ops.h"
20 NR::Matrix const sp_desktop_root2dt_affine (SPDesktop const *dt)
21 {
22 SPRoot const *root = SP_ROOT(SP_DOCUMENT_ROOT(dt->doc()));
23 return root->c2p * dt->doc2dt();
24 }
26 NR::Matrix const sp_desktop_dt2root_affine (SPDesktop const *dt)
27 {
28 return sp_desktop_root2dt_affine(dt).inverse();
29 }
31 NR::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, NR::Point const p)
32 {
33 return p * sp_desktop_root2dt_affine(dt);
34 }
36 NR::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, NR::Point const p)
37 {
38 return p * sp_desktop_dt2root_affine(dt);
39 }