255 |
*/ |
*/ |
256 |
class ScaleXYZCoords { |
class ScaleXYZCoords { |
257 |
ZVec vec; |
ZVec vec; |
|
friend class DistortCoords; |
|
258 |
public: |
public: |
259 |
enum { NParams = 3 }; |
enum { NParams = 3 }; |
260 |
template<class Ptr> void setParams(Ptr p) { |
template<class Ptr> void setParams(Ptr p) { |
288 |
} |
} |
289 |
} ; |
} ; |
290 |
|
|
291 |
|
/** Isotropically distorted coordinate system. |
|
/** Distorted coordinate system. |
|
292 |
* Parameter layout: x, y (of center), log(mag), log(min), w, h. |
* Parameter layout: x, y (of center), log(mag), log(min), w, h. |
293 |
* W and h give the width and height in the inside coordinate system |
* W and h give the width and height in the inside coordinate system |
294 |
* of the zoomed area. |
* of the zoomed area. |
295 |
*/ |
*/ |
296 |
class DistortCoords { |
template<class F> class DistortCoords { |
297 |
|
friend class DistortCoords<typename F::InverseType>; |
298 |
float x, y; |
float x, y; |
299 |
float w, h; |
float w, h; |
300 |
float mmin; |
float mmin; |
301 |
float mmax; |
float mmax; |
302 |
Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> distort; |
F distort; |
303 |
public: |
public: |
304 |
enum { NParams = 6 }; |
enum { NParams = 6 }; |
305 |
template<class Ptr> void setParams(Ptr p) { |
template<class Ptr> void setParams(Ptr p) { |
309 |
mmin = exp(p[3]); |
mmin = exp(p[3]); |
310 |
w = p[4]; |
w = p[4]; |
311 |
h = p[5]; |
h = p[5]; |
312 |
distort.f = Fisheye::scalar_mag_atan(mmax / mmin); |
distort.setMag(mmax / mmin); |
313 |
} |
} |
314 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
315 |
ZPt p = ZPt((from.x-x) / w, (from.y-y)/ h, from.z); |
ZPt p = ZPt((from.x-x) / w, (from.y-y)/ h, from.z); |
319 |
to.y *= mmin; |
to.y *= mmin; |
320 |
to.x += x; to.y += y; |
to.x += x; to.y += y; |
321 |
} |
} |
322 |
typedef ScaleXYZCoords InverseType; // XXX !!! |
typedef DistortCoords<typename F::InverseType> InverseType; // XXX !!! |
323 |
ScaleXYZCoords inverseTransform() { |
InverseType inverseTransform() { |
324 |
ScaleXYZCoords inv; |
InverseType inv; |
325 |
inv.vec = ZVec(1,1,1); // XXX! |
inv.x = x; |
326 |
|
inv.y = y; |
327 |
|
inv.w = w; |
328 |
|
inv.h = h; |
329 |
|
inv.mmin = 1/mmin; |
330 |
|
inv.mmax = mmax; |
331 |
|
inv.distort.setMag(mmax/mmin); |
332 |
return inv; |
return inv; |
333 |
} |
} |
334 |
bool canPerformGL() { return false; } |
bool canPerformGL() { return false; } |
361 |
0, |
0, |
362 |
new Factory<AffineXYCoords>(), |
new Factory<AffineXYCoords>(), |
363 |
new Factory<RotateXYCoords>(), |
new Factory<RotateXYCoords>(), |
364 |
new Factory<DistortCoords>(), |
new Factory<DistortCoords<Fisheye::vector_mag_isotropic<Fisheye::scalar_mag_atan> > >(), |
365 |
new Factory<RotateXYZCoords>(), |
new Factory<RotateXYZCoords>(), |
366 |
new Factory<ScaleXYZCoords>(), |
new Factory<ScaleXYZCoords>(), |
367 |
0 |
0 |