SphericMirrorCalculator.cpp   SphericMirrorCalculator.cpp 
skipping to change at line 40 skipping to change at line 40
const float mirror_radius(conf.value("spheric_mirror/mirror_radius",0.25) .toFloat()); const float mirror_radius(conf.value("spheric_mirror/mirror_radius",0.25) .toFloat());
DomeCenter = mirror_position * (-1.0/mirror_radius); DomeCenter = mirror_position * (-1.0/mirror_radius);
const float dome_radius(conf.value("spheric_mirror/dome_radius",2.5).toFl oat()); const float dome_radius(conf.value("spheric_mirror/dome_radius",2.5).toFl oat());
DomeRadius = dome_radius / mirror_radius; DomeRadius = dome_radius / mirror_radius;
const Vec3f projector_position( const Vec3f projector_position(
conf.value("spheric_mirror/projector_position_x",0.0).toFloat(), conf.value("spheric_mirror/projector_position_x",0.0).toFloat(),
conf.value("spheric_mirror/projector_position_y",1.0).toFloat(), conf.value("spheric_mirror/projector_position_y",1.0).toFloat(),
conf.value("spheric_mirror/projector_position_z",-0.2).toFloat()); conf.value("spheric_mirror/projector_position_z",-0.2).toFloat());
P = (projector_position - mirror_position) * (1.0/mirror_radius); P = (projector_position - mirror_position) * (1.0/mirror_radius);
PP = P.lengthSquared(); PP = P.lengthSquared();
lP = sqrt(PP); lP = std::sqrt(PP);
p = P * (1.0/lP); p = P * (1.0/lP);
float image_distance_div_height float image_distance_div_height
= conf.value("spheric_mirror/image_distance_div_he ight",-1e100).toFloat(); = conf.value("spheric_mirror/image_distance_div_he ight",-1e100).toFloat();
if (image_distance_div_height <= -1e100) if (image_distance_div_height <= -1e100)
{ const float scaling_factor = conf.value("spheric_mirror/scaling_factor" , 0.8).toFloat(); { const float scaling_factor = conf.value("spheric_mirror/scaling_factor" , 0.8).toFloat();
image_distance_div_height = sqrt(PP-1.0) * scaling_factor; image_distance_div_height = std::sqrt(PP-1.0) * scaling_factor;
qDebug() << "INFO: spheric_mirror:scaling_factor is deprecated and may be removed in future versions."; qDebug() << "INFO: spheric_mirror:scaling_factor is deprecated and may be removed in future versions.";
qDebug() << " In order to keep your setup unchanged, please use sp heric_mirror:image_distance_div_height = " qDebug() << " In order to keep your setup unchanged, please use sp heric_mirror:image_distance_div_height = "
<< image_distance_div_height << " instead"; << image_distance_div_height << " instead";
} }
horzZoomFactor = conf.value("spheric_mirror/flip_horz",true).toBool() horzZoomFactor = conf.value("spheric_mirror/flip_horz",true).toBool()
? (-image_distance_div_height) ? (-image_distance_div_height)
: image_distance_div_height; : image_distance_div_height;
vertZoomFactor = conf.value("spheric_mirror/flip_vert",false).toBool() vertZoomFactor = conf.value("spheric_mirror/flip_vert",false).toBool()
? (-image_distance_div_height) ? (-image_distance_div_height)
: image_distance_div_height; : image_distance_div_height;
skipping to change at line 182 skipping to change at line 182
y /= vertZoomFactor; y /= vertZoomFactor;
v[0] = alphaDeltaPhi[0]*x + alphaDeltaPhi[1] + alphaDeltaPhi[2]*y; v[0] = alphaDeltaPhi[0]*x + alphaDeltaPhi[1] + alphaDeltaPhi[2]*y;
v[1] = alphaDeltaPhi[3]*x + alphaDeltaPhi[4] + alphaDeltaPhi[5]*y; v[1] = alphaDeltaPhi[3]*x + alphaDeltaPhi[4] + alphaDeltaPhi[5]*y;
v[2] = alphaDeltaPhi[6]*x + alphaDeltaPhi[7] + alphaDeltaPhi[8]*y; v[2] = alphaDeltaPhi[6]*x + alphaDeltaPhi[7] + alphaDeltaPhi[8]*y;
const float vv = v.dot(v); const float vv = v.dot(v);
const float Pv = P.dot(v); const float Pv = P.dot(v);
const float discr = Pv*Pv-(P.dot(P)-1.0)*vv; const float discr = Pv*Pv-(P.dot(P)-1.0)*vv;
if (discr < 0) { if (discr < 0) {
return false; return false;
} }
const Vec3f Q = P + v*((-Pv-sqrt(discr))/vv); const Vec3f Q = P + v*((-Pv-std::sqrt(discr))/vv);
const Vec3f w = v - Q*(2*v.dot(Q)); const Vec3f w = v - Q*(2*v.dot(Q));
const Vec3f MQ = Q - DomeCenter; const Vec3f MQ = Q - DomeCenter;
float f = -MQ.dot(w); float f = -MQ.dot(w);
f += sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv); f += std::sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv);
const Vec3f S = Q + w*(f/vv); const Vec3f S = Q + w*(f/vv);
v = S - DomeCenter; v = S - DomeCenter;
v *= (1.0/DomeRadius); v *= (1.0/DomeRadius);
return true; return true;
} }
bool SphericMirrorCalculator::retransform(float x,float y, bool SphericMirrorCalculator::retransform(float x,float y,
Vec3f &v, Vec3f &v,
Vec3f &vX,Vec3f &vY) const { Vec3f &vX,Vec3f &vY) const {
x /= horzZoomFactor; x /= horzZoomFactor;
skipping to change at line 228 skipping to change at line 228
const float PvX = P.dot(vX); const float PvX = P.dot(vX);
const float PvY = P.dot(vY); const float PvY = P.dot(vY);
const float discr = Pv*Pv-(P.dot(P)-1.0)*vv; const float discr = Pv*Pv-(P.dot(P)-1.0)*vv;
const float discr_x = 2.0*Pv*PvX-(P.dot(P)-1.0)*vvX; const float discr_x = 2.0*Pv*PvX-(P.dot(P)-1.0)*vvX;
const float discr_y = 2.0*Pv*PvY-(P.dot(P)-1.0)*vvY; const float discr_y = 2.0*Pv*PvY-(P.dot(P)-1.0)*vvY;
if (discr < 0) { if (discr < 0) {
return false; return false;
} }
const Vec3f Q = P + v*((-Pv-sqrt(discr))/vv); const Vec3f Q = P + v*((-Pv-std::sqrt(discr))/vv);
const Vec3f Q_x = vX*((-Pv-sqrt(discr))/vv) const Vec3f Q_x = vX*((-Pv-std::sqrt(discr))/vv)
+ v*( (vv*(-PvX-0.5*discr_x/sqrt(discr)) + v*( (vv*(-PvX-0.5*discr_x/std::sqrt(discr))
-vvX*(-Pv-sqrt(discr))) /(vv*vv)); -vvX*(-Pv-std::sqrt(discr))) /(vv*vv));
const Vec3f Q_y = vY*((-Pv-sqrt(discr))/vv) const Vec3f Q_y = vY*((-Pv-std::sqrt(discr))/vv)
+ v*( (vv*(-PvY-0.5*discr_y/sqrt(discr)) + v*( (vv*(-PvY-0.5*discr_y/std::sqrt(discr))
-vvY*(-Pv-sqrt(discr))) /(vv*vv)); -vvY*(-Pv-std::sqrt(discr))) /(vv*vv));
const Vec3f w = v - Q*(2*v.dot(Q)); const Vec3f w = v - Q*(2*v.dot(Q));
const Vec3f w_x = vX - Q_x*(2*v.dot(Q)) - Q*(2*(vX.dot(Q)+v.dot(Q_x))); const Vec3f w_x = vX - Q_x*(2*v.dot(Q)) - Q*(2*(vX.dot(Q)+v.dot(Q_x)));
const Vec3f w_y = vY - Q_y*(2*v.dot(Q)) - Q*(2*(vY.dot(Q)+v.dot(Q_y))); const Vec3f w_y = vY - Q_y*(2*v.dot(Q)) - Q*(2*(vY.dot(Q)+v.dot(Q_y)));
const Vec3f MQ = Q - DomeCenter; const Vec3f MQ = Q - DomeCenter;
// MQ_x = Q_x // MQ_x = Q_x
// MQ_y = Q_y // MQ_y = Q_y
float f = -MQ.dot(w); float f = -MQ.dot(w);
float f_x = -Q_x.dot(w)-MQ.dot(w_x); float f_x = -Q_x.dot(w)-MQ.dot(w_x);
float f_y = -Q_y.dot(w)-MQ.dot(w_y); float f_y = -Q_y.dot(w)-MQ.dot(w_y);
float f1 = f + sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv); float f1 = f + std::sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv);
float f1_x = f_x + 0.5*(2*f*f_x - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vvX float f1_x = f_x + 0.5*(2*f*f_x - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vvX
- 2*MQ.dot(Q_x)*vv ) - 2*MQ.dot(Q_x)*vv )
/ sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv); / std::sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv);
float f1_y = f_y + 0.5*(2*f*f_y - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vvY float f1_y = f_y + 0.5*(2*f*f_y - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vvY
- 2*MQ.dot(Q_y)*vv ) - 2*MQ.dot(Q_y)*vv )
/ sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv); / std::sqrt(f*f - (MQ.dot(MQ)-DomeRadius*DomeRadius)*vv);
const Vec3f S = Q + w*(f1/vv); const Vec3f S = Q + w*(f1/vv);
const Vec3f S_x = Q_x + w*((vv*f1_x-vvX*f1)/(vv*vv)) + w_x*(f1/vv); const Vec3f S_x = Q_x + w*((vv*f1_x-vvX*f1)/(vv*vv)) + w_x*(f1/vv);
const Vec3f S_y = Q_y + w*((vv*f1_y-vvY*f1)/(vv*vv)) + w_y*(f1/vv); const Vec3f S_y = Q_y + w*((vv*f1_y-vvY*f1)/(vv*vv)) + w_y*(f1/vv);
v = S - DomeCenter; v = S - DomeCenter;
vX = S_x; vX = S_x;
vY = S_y; vY = S_y;
v *= (1.0/DomeRadius); v *= (1.0/DomeRadius);
 End of changes. 8 change blocks. 
14 lines changed or deleted 14 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/