36 #ifndef __SBNW_TRANSFORM_H_
37 #define __SBNW_TRANSFORM_H_
42 #include "graphfab/layout/point.h"
54 : u(a), v(b), x(c), y(d) {}
58 Real det()
const {
return u*y - v*x; }
61 class _GraphfabExport Affine2d {
71 _e[0] = 1.; _e[1] = 0.; _e[2] = 0.;
72 _e[3] = 0.; _e[4] = 1.; _e[5] = 0.;
73 _e[6] = 0.; _e[7] = 0.; _e[8] = 1.;
79 _e[0] = a; _e[1] = b; _e[2] = c;
80 _e[3] = u; _e[4] = v; _e[5] = w;
81 _e[6] = x; _e[7] = y; _e[8] = z;
91 Real rc(
int r,
int c)
const {
92 AT(0 <= r && r < 3,
"Row out of range");
93 AT(0 <= c && c < 3,
"Column out of range");
98 Real& rcref(
int r,
int c) {
99 AT(0 <= r && r < 3,
"Row out of range");
100 AT(0 <= c && c < 3,
"Column out of range");
105 Real scaleFactor()
const {
109 void set(
int i,
int j,
Real val) { rcref(i,j) = val; }
113 static Affine2d makeXlate(
Real x,
Real y) {
120 static Affine2d makeXlate(
const Point& p) {
return makeXlate(p.x, p.y); }
122 static Affine2d makeScale(
Real x,
Real y) {
131 static Affine2d fromPoints(
const Point& x,
const Point& y,
const Point& z) {
140 static Affine2d fromBasis(
const Point& u,
const Point& v,
const Point& disp) {
148 static Affine2d fromBox(
const Box& b) {
149 return fromPoints(Point(b.getMax().x, 0), Point(0, b.getMax().y), b.getMin());
152 static Affine2d sendTo(
const Box& src,
const Box& dst) {
153 return fromBox(dst)*fromBox(src).inv();
156 static Affine2d FitToWindow(
const Box& src,
const Box& dst);
160 Point operator*(
const Point& x)
const;
162 Box operator*(
const Box& x)
const;
164 Affine2d operator*(
const Real& k)
const;
166 Affine2d operator/(
const Real& k)
const {
return (*
this)*(1./k); }
170 static Affine2d compose(
const Affine2d& u,
const Affine2d& v);
172 Affine2d operator*(
const Affine2d& z)
const {
return compose(*
this, z); }
175 Point applyLinearOnly(
const Point& x)
const;
177 Point getScale()
const {
178 return Point(applyLinearOnly(Point(1, 0)).mag(),
179 applyLinearOnly(Point(0, 1)).mag());
182 Point getDisplacement()
const {
183 return Point(rc(0, 2), rc(1, 2));
188 Affine2d cofactors()
const;
190 Real cofactor(
int i,
int j)
const;
193 cutout getCutout(
int r,
int c)
const;
198 Point xformPoint(
const Point& p,
const Affine2d& t);
199 Box xformBox(
const Box& b,
const Affine2d& t);
204 _GraphfabExport std::ostream& operator<<(std::ostream& o,
const Affine2d& t);
SAGITTARIUS_REAL Real
Make Real visible to C. Consider letting Real lie in top namespace.
Definition: SagittariusCommon.h:136
Definition: SagittariusCommon.cpp:38