12 #ifndef __SBNW_TRANSFORM_H_ 13 #define __SBNW_TRANSFORM_H_ 26 namespace LibsbmlDraw {
30 : u(a), v(b), x(c), y(d) {}
34 Real det()
const {
return u*y - v*x; }
37 class _GraphfabExport Affine2d {
47 _e[0] = 1.; _e[1] = 0.; _e[2] = 0.;
48 _e[3] = 0.; _e[4] = 1.; _e[5] = 0.;
49 _e[6] = 0.; _e[7] = 0.; _e[8] = 1.;
55 _e[0] = a; _e[1] = b; _e[2] = c;
56 _e[3] = u; _e[4] = v; _e[5] = w;
57 _e[6] = x; _e[7] = y; _e[8] = z;
67 Real rc(
int r,
int c)
const {
68 AT(0 <= r && r < 3,
"Row out of range");
69 AT(0 <= c && c < 3,
"Column out of range");
74 Real& rcref(
int r,
int c) {
75 AT(0 <= r && r < 3,
"Row out of range");
76 AT(0 <= c && c < 3,
"Column out of range");
81 Real scaleFactor()
const {
85 void set(
int i,
int j,
Real val) { rcref(i,j) = val; }
89 static Affine2d makeXlate(
Real x,
Real y) {
96 static Affine2d makeXlate(
const Point& p) {
return makeXlate(p.x, p.y); }
98 static Affine2d makeScale(
Real x,
Real y) {
107 static Affine2d fromPoints(
const Point& x,
const Point& y,
const Point& z) {
116 static Affine2d fromBasis(
const Point& u,
const Point& v,
const Point& disp) {
124 static Affine2d fromBox(
const Box& b) {
125 return fromPoints(Point(b.getMax().x, 0), Point(0, b.getMax().y), b.getMin());
128 static Affine2d sendTo(
const Box& src,
const Box& dst) {
129 return fromBox(dst)*fromBox(src).inv();
132 static Affine2d FitToWindow(
const Box& src,
const Box& dst);
136 Point operator*(
const Point& x)
const;
138 Box operator*(
const Box& x)
const;
140 Affine2d operator*(
const Real& k)
const;
142 Affine2d operator/(
const Real& k)
const {
return (*
this)*(1./k); }
146 static Affine2d compose(
const Affine2d& u,
const Affine2d& v);
148 Affine2d operator*(
const Affine2d& z)
const {
return compose(*
this, z); }
151 Point applyLinearOnly(
const Point& x)
const;
153 Point getScale()
const {
154 return Point(applyLinearOnly(Point(1, 0)).mag(),
155 applyLinearOnly(Point(0, 1)).mag());
158 Point getDisplacement()
const {
159 return Point(rc(0, 2), rc(1, 2));
164 Affine2d cofactors()
const;
166 Real cofactor(
int i,
int j)
const;
169 cutout getCutout(
int r,
int c)
const;
174 Point xformPoint(
const Point& p,
const Affine2d& t);
175 Box xformBox(
const Box& b,
const Affine2d& t);
180 _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:112