129 |
* of the zoomed area. |
* of the zoomed area. |
130 |
*/ |
*/ |
131 |
class DistortCoords : public CoordSys { |
class DistortCoords : public CoordSys { |
132 |
|
float x, y; |
133 |
|
float w, h; |
134 |
float mmin; |
float mmin; |
135 |
float mmax; |
float mmax; |
136 |
Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort; |
Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort; |
138 |
enum { NParams = 6 }; |
enum { NParams = 6 }; |
139 |
virtual void setParams(float *params) { |
virtual void setParams(float *params) { |
140 |
CoordSys::setParams(params); |
CoordSys::setParams(params); |
141 |
|
x = params[0]; |
142 |
|
y = params[1]; |
143 |
mmax = exp(params[2]); |
mmax = exp(params[2]); |
144 |
mmin = exp(params[3]); |
mmin = exp(params[3]); |
145 |
|
w = params[4]; |
146 |
|
h = params[5]; |
147 |
distort.f = Fisheye::scalar_mag_atan(mmax / mmin); |
distort.f = Fisheye::scalar_mag_atan(mmax / mmin); |
148 |
} |
} |
149 |
virtual ZPt transform(const ZPt &p) const { |
virtual ZPt transform(const ZPt &p) const { |
157 |
super->vertex(mp); |
super->vertex(mp); |
158 |
} |
} |
159 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
160 |
to = distort(from); |
ZPt p = ZPt((from.x-x) / w, (from.y-y)/ h, from.z); |
161 |
|
to = distort(p); |
162 |
|
to.x *= w; to.y *= h; |
163 |
|
to.x += x; to.y += y; |
164 |
to.x *= mmin; |
to.x *= mmin; |
165 |
to.y *= mmin; |
to.y *= mmin; |
166 |
} |
} |