StelProjectorClasses.cpp   StelProjectorClasses.cpp 
skipping to change at line 42 skipping to change at line 42
bool StelProjectorPerspective::backward(Vec3d &v) const bool StelProjectorPerspective::backward(Vec3d &v) const
{ {
v[2] = std::sqrt(1.0/(1.0+v[0]*v[0]+v[1]*v[1])); v[2] = std::sqrt(1.0/(1.0+v[0]*v[0]+v[1]*v[1]));
v[0] *= v[2]; v[0] *= v[2];
v[1] *= v[2]; v[1] *= v[2];
v[2] = -v[2]; v[2] = -v[2];
return true; return true;
} }
double StelProjectorPerspective::fovToViewScalingFactor(double fov) const float StelProjectorPerspective::fovToViewScalingFactor(float fov) const
{ {
return std::tan(fov); return std::tan(fov);
} }
double StelProjectorPerspective::viewScalingFactorToFov(double vsf) const float StelProjectorPerspective::viewScalingFactorToFov(float vsf) const
{ {
return std::atan(vsf); return std::atan(vsf);
} }
double StelProjectorPerspective::deltaZoom(double fov) const float StelProjectorPerspective::deltaZoom(float fov) const
{ {
const double vsf = fovToViewScalingFactor(fov); const float vsf = fovToViewScalingFactor(fov);
// deriv_viewScalingFactorToFov(vsf) = 1.0 / (1.0+vsf*vsf) // deriv_viewScalingFactorToFov(vsf) = 1.0 / (1.0+vsf*vsf)
// return vsf*deriv_viewScalingFactorToFov(vsf)) // return vsf*deriv_viewScalingFactorToFov(vsf))
return vsf / (1.0+vsf*vsf); return vsf / (1.f+vsf*vsf);
} }
QString StelProjectorEqualArea::getNameI18() const QString StelProjectorEqualArea::getNameI18() const
{ {
return q_("Equal Area"); return q_("Equal Area");
} }
QString StelProjectorEqualArea::getDescriptionI18() const QString StelProjectorEqualArea::getDescriptionI18() const
{ {
return q_("The full name of this projection method is, <i>Lambert az imuthal equal-area projection</i>. It preserves the area but not the angle. "); return q_("The full name of this projection method is, <i>Lambert az imuthal equal-area projection</i>. It preserves the area but not the angle. ");
skipping to change at line 90 skipping to change at line 90
else else
{ {
l = std::sqrt(l); l = std::sqrt(l);
v[0] *= l; v[0] *= l;
v[1] *= l; v[1] *= l;
v[2] = 0.5*dq - 1.0; v[2] = 0.5*dq - 1.0;
} }
return true; return true;
} }
double StelProjectorEqualArea::fovToViewScalingFactor(double fov) const float StelProjectorEqualArea::fovToViewScalingFactor(float fov) const
{ {
return 2.0 * std::sin(0.5 * fov); return 2.f * std::sin(0.5f * fov);
} }
double StelProjectorEqualArea::viewScalingFactorToFov(double vsf) const float StelProjectorEqualArea::viewScalingFactorToFov(float vsf) const
{ {
return 2.0 * std::asin(0.5 * vsf); return 2.f * std::asin(0.5f * vsf);
} }
double StelProjectorEqualArea::deltaZoom(double fov) const float StelProjectorEqualArea::deltaZoom(float fov) const
{ {
// deriv_viewScalingFactorToFov(vsf) = 2.0 / sqrt(4.0-vsf*vsf); return fov;
// const double vsf = fovToViewScalingFactor(fov);
// return vsf*deriv_viewScalingFactorToFov(vsf)) = 2.0*vsf / sqrt(4.0-vsf*v
sf);
return fov;
} }
QString StelProjectorStereographic::getNameI18() const QString StelProjectorStereographic::getNameI18() const
{ {
return q_("Stereographic"); return q_("Stereographic");
} }
QString StelProjectorStereographic::getDescriptionI18() const QString StelProjectorStereographic::getDescriptionI18() const
{ {
return q_("Stereographic projection is known since the antiquity and was originally known as the planisphere projection. It preserves the angle s at which curves cross each other but it does not preserve area."); return q_("Stereographic projection is known since the antiquity and was originally known as the planisphere projection. It preserves the angle s at which curves cross each other but it does not preserve area.");
} }
bool StelProjectorStereographic::backward(Vec3d &v) const bool StelProjectorStereographic::backward(Vec3d &v) const
{ {
const double lqq = 0.25*(v[0]*v[0] + v[1]*v[1]); const double lqq = 0.25*(v[0]*v[0] + v[1]*v[1]);
v[2] = lqq - 1.0; v[2] = lqq - 1.0;
v *= (1.0 / (lqq + 1.0)); v *= (1.0 / (lqq + 1.0));
return true; return true;
} }
double StelProjectorStereographic::fovToViewScalingFactor(double fov) const float StelProjectorStereographic::fovToViewScalingFactor(float fov) const
{ {
return 2.0 * std::tan(0.5 * fov); return 2.f * std::tan(0.5f * fov);
} }
double StelProjectorStereographic::viewScalingFactorToFov(double vsf) const float StelProjectorStereographic::viewScalingFactorToFov(float vsf) const
{ {
return 2.0 * std::atan(0.5 * vsf); return 2.f * std::atan(0.5f * vsf);
} }
double StelProjectorStereographic::deltaZoom(double fov) const float StelProjectorStereographic::deltaZoom(float fov) const
{ {
const double vsf = fovToViewScalingFactor(fov); const float vsf = fovToViewScalingFactor(fov);
// deriv_viewScalingFactorToFov(vsf) = 4.0 / (4.0+vsf*vsf) return 4.f*vsf / (4.f+vsf*vsf);
// return vsf*deriv_viewScalingFactorToFov(vsf))
return 4.0*vsf / (4.0+vsf*vsf);
} }
QString StelProjectorFisheye::getNameI18() const QString StelProjectorFisheye::getNameI18() const
{ {
return q_("Fish-eye"); return q_("Fish-eye");
} }
QString StelProjectorFisheye::getDescriptionI18() const QString StelProjectorFisheye::getDescriptionI18() const
{ {
return q_("In fish-eye projection, or <i>azimuthal equidistant proje ction</i>, straight lines become curves when they appear a large angular di stance from the centre of the field of view (like the distortions seen with very wide angle camera lenses)."); return q_("In fish-eye projection, or <i>azimuthal equidistant proje ction</i>, straight lines become curves when they appear a large angular di stance from the centre of the field of view (like the distortions seen with very wide angle camera lenses).");
skipping to change at line 164 skipping to change at line 159
bool StelProjectorFisheye::backward(Vec3d &v) const bool StelProjectorFisheye::backward(Vec3d &v) const
{ {
const double a = std::sqrt(v[0]*v[0]+v[1]*v[1]); const double a = std::sqrt(v[0]*v[0]+v[1]*v[1]);
const double f = (a > 0.0) ? (std::sin(a) / a) : 1.0; const double f = (a > 0.0) ? (std::sin(a) / a) : 1.0;
v[0] *= f; v[0] *= f;
v[1] *= f; v[1] *= f;
v[2] = -std::cos(a); v[2] = -std::cos(a);
return (a < M_PI); return (a < M_PI);
} }
double StelProjectorFisheye::fovToViewScalingFactor(double fov) const float StelProjectorFisheye::fovToViewScalingFactor(float fov) const
{ {
return fov; return fov;
} }
double StelProjectorFisheye::viewScalingFactorToFov(double vsf) const float StelProjectorFisheye::viewScalingFactorToFov(float vsf) const
{ {
return vsf; return vsf;
} }
double StelProjectorFisheye::deltaZoom(double fov) const float StelProjectorFisheye::deltaZoom(float fov) const
{ {
return fov; return fov;
} }
QString StelProjectorHammer::getNameI18() const QString StelProjectorHammer::getNameI18() const
{ {
return q_("Hammer-Aitoff"); return q_("Hammer-Aitoff");
} }
QString StelProjectorHammer::getDescriptionI18() const QString StelProjectorHammer::getDescriptionI18() const
skipping to change at line 203 skipping to change at line 198
const bool ret = 0.25*v[0]*v[0]+v[1]*v[1]<2.0; // This is stolen fro m glunatic const bool ret = 0.25*v[0]*v[0]+v[1]*v[1]<2.0; // This is stolen fro m glunatic
const double alpha = 2.*std::atan2(z*v[0],(2.*(2.*zsq-1.))); const double alpha = 2.*std::atan2(z*v[0],(2.*(2.*zsq-1.)));
const double delta = std::asin(v[1]*z); const double delta = std::asin(v[1]*z);
const double cd = std::cos(delta); const double cd = std::cos(delta);
v[2] = - cd * std::cos(alpha); v[2] = - cd * std::cos(alpha);
v[0] = cd * std::sin(alpha); v[0] = cd * std::sin(alpha);
v[1] = v[1]*z; v[1] = v[1]*z;
return ret; return ret;
} }
double StelProjectorHammer::fovToViewScalingFactor(double fov) const float StelProjectorHammer::fovToViewScalingFactor(float fov) const
{ {
return fov; return fov;
} }
double StelProjectorHammer::viewScalingFactorToFov(double vsf) const float StelProjectorHammer::viewScalingFactorToFov(float vsf) const
{ {
return vsf; return vsf;
} }
double StelProjectorHammer::deltaZoom(double fov) const float StelProjectorHammer::deltaZoom(float fov) const
{ {
return fov; return fov;
} }
QString StelProjectorCylinder::getNameI18() const QString StelProjectorCylinder::getNameI18() const
{ {
return q_("Cylinder"); return q_("Cylinder");
} }
QString StelProjectorCylinder::getDescriptionI18() const QString StelProjectorCylinder::getDescriptionI18() const
{ {
return q_("The full name of this projection mode is <i>cylindrical e quidistant projection</i>. With this projection all parallels are equally s paced."); return q_("The full name of this projection mode is <i>cylindrical e quidistant projection</i>. With this projection all parallels are equally s paced.");
} }
bool StelProjectorCylinder::forward(Vec3d &v) const bool StelProjectorCylinder::forward(Vec3f &v) const
{ {
const double r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
const bool rval = (-r < v[1] && v[1] < r); const bool rval = (-r < v[1] && v[1] < r);
const double alpha = std::atan2(v[0],-v[2]); const float alpha = std::atan2(v[0],-v[2]);
const double delta = std::asin(v[1]/r); const float delta = std::asin(v[1]/r);
v[0] = alpha; v[0] = alpha;
v[1] = delta; v[1] = delta;
v[2] = r; v[2] = r;
return rval; return rval;
} }
bool StelProjectorCylinder::backward(Vec3d &v) const bool StelProjectorCylinder::backward(Vec3d &v) const
{ {
const bool rval = v[1]<M_PI_2 && v[1]>-M_PI_2 && v[0]>-M_PI && v[0]< M_PI; const bool rval = v[1]<M_PI_2 && v[1]>-M_PI_2 && v[0]>-M_PI && v[0]< M_PI;
const double cd = std::cos(v[1]); const double cd = std::cos(v[1]);
v[2] = - cd * std::cos(v[0]); v[2] = - cd * std::cos(v[0]);
v[0] = cd * std::sin(v[0]); v[0] = cd * std::sin(v[0]);
v[1] = std::sin(v[1]); v[1] = std::sin(v[1]);
return rval; return rval;
} }
double StelProjectorCylinder::fovToViewScalingFactor(double fov) const float StelProjectorCylinder::fovToViewScalingFactor(float fov) const
{ {
return fov; return fov;
} }
double StelProjectorCylinder::viewScalingFactorToFov(double vsf) const float StelProjectorCylinder::viewScalingFactorToFov(float vsf) const
{ {
return vsf; return vsf;
} }
double StelProjectorCylinder::deltaZoom(double fov) const float StelProjectorCylinder::deltaZoom(float fov) const
{ {
return fov; return fov;
} }
QString StelProjectorMercator::getNameI18() const QString StelProjectorMercator::getNameI18() const
{ {
return q_("Mercator"); return q_("Mercator");
} }
QString StelProjectorMercator::getDescriptionI18() const QString StelProjectorMercator::getDescriptionI18() const
{ {
return q_("The mercator projection is one of the most used world map projection. It preserves direction and shapes but distorts size, in an inc reasing degree away from the equator."); return q_("The mercator projection is one of the most used world map projection. It preserves direction and shapes but distorts size, in an inc reasing degree away from the equator.");
} }
bool StelProjectorMercator::forward(Vec3d &v) const bool StelProjectorMercator::forward(Vec3f &v) const
{ {
const double r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
const bool rval = (-r < v[1] && v[1] < r); const bool rval = (-r < v[1] && v[1] < r);
const double sin_delta = v[1]/r; const float sin_delta = v[1]/r;
v[0] = std::atan2(v[0],-v[2]); v[0] = std::atan2(v[0],-v[2]);
v[1] = 0.5*std::log((1.0+sin_delta)/(1.0-sin_delta)); v[1] = 0.5f*std::log((1.f+sin_delta)/(1.f-sin_delta));
v[2] = r; v[2] = r;
return rval; return rval;
} }
bool StelProjectorMercator::backward(Vec3d &v) const bool StelProjectorMercator::backward(Vec3d &v) const
{ {
const bool rval = v[1]<M_PI_2 && v[1]>-M_PI_2 && v[0]>-M_PI && v[0]< M_PI; const bool rval = v[1]<M_PI_2 && v[1]>-M_PI_2 && v[0]>-M_PI && v[0]< M_PI;
const double E = std::exp(v[1]); const double E = std::exp(v[1]);
const double h = E*E; const double h = E*E;
const double h1 = 1.0/(1.0+h); const double h1 = 1.0/(1.0+h);
const double sin_delta = (h-1.0)*h1; const double sin_delta = (h-1.0)*h1;
const double cos_delta = 2.0*E*h1; const double cos_delta = 2.0*E*h1;
v[2] = - cos_delta * std::cos(v[0]); v[2] = - cos_delta * std::cos(v[0]);
v[0] = cos_delta * std::sin(v[0]); v[0] = cos_delta * std::sin(v[0]);
v[1] = sin_delta; v[1] = sin_delta;
return rval; return rval;
} }
double StelProjectorMercator::fovToViewScalingFactor(double fov) const float StelProjectorMercator::fovToViewScalingFactor(float fov) const
{ {
return fov; return fov;
} }
double StelProjectorMercator::viewScalingFactorToFov(double vsf) const float StelProjectorMercator::viewScalingFactorToFov(float vsf) const
{ {
return vsf; return vsf;
} }
double StelProjectorMercator::deltaZoom(double fov) const float StelProjectorMercator::deltaZoom(float fov) const
{ {
return fov; return fov;
} }
QString StelProjectorOrthographic::getNameI18() const QString StelProjectorOrthographic::getNameI18() const
{ {
return q_("Orthographic"); return q_("Orthographic");
} }
QString StelProjectorOrthographic::getDescriptionI18() const QString StelProjectorOrthographic::getDescriptionI18() const
{ {
return q_("Orthographic projection is related to perspective project ion, but the point of perspective is set to an infinite distance."); return q_("Orthographic projection is related to perspective project ion, but the point of perspective is set to an infinite distance.");
} }
bool StelProjectorOrthographic::forward(Vec3d &v) const bool StelProjectorOrthographic::forward(Vec3f &v) const
{ {
const double r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
const double h = 1.0/r; const float h = 1.f/r;
v[0] *= h; v[0] *= h;
v[1] *= h; v[1] *= h;
const bool rval = (v[2] <= 0.0); const bool rval = (v[2] <= 0.f);
v[2] = r; v[2] = r;
return rval; return rval;
} }
bool StelProjectorOrthographic::backward(Vec3d &v) const bool StelProjectorOrthographic::backward(Vec3d &v) const
{ {
const double dq = v[0]*v[0] + v[1]*v[1]; const double dq = v[0]*v[0] + v[1]*v[1];
double h = 1.0 - dq; double h = 1.0 - dq;
if (h < 0) { if (h < 0) {
h = 1.0/std::sqrt(dq); h = 1.0/std::sqrt(dq);
v[0] *= h; v[0] *= h;
v[1] *= h; v[1] *= h;
v[2] = 0.0; v[2] = 0.0;
return false; return false;
} }
v[2] = -std::sqrt(h); v[2] = -std::sqrt(h);
return true; return true;
} }
double StelProjectorOrthographic::fovToViewScalingFactor(double fov) const float StelProjectorOrthographic::fovToViewScalingFactor(float fov) const
{ {
return std::sin(fov); return std::sin(fov);
} }
double StelProjectorOrthographic::viewScalingFactorToFov(double vsf) const float StelProjectorOrthographic::viewScalingFactorToFov(float vsf) const
{ {
return std::asin(vsf); return std::asin(vsf);
} }
double StelProjectorOrthographic::deltaZoom(double fov) const float StelProjectorOrthographic::deltaZoom(float fov) const
{ {
return fov; return fov;
} }
QString StelProjector2d::getNameI18() const QString StelProjector2d::getNameI18() const
{ {
return "2d"; return "2d";
} }
QString StelProjector2d::getDescriptionI18() const QString StelProjector2d::getDescriptionI18() const
{ {
return "Simple 2d projection for internal use."; return "Simple 2d projection for internal use.";
} }
bool StelProjector2d::forward(Vec3d &v) const bool StelProjector2d::forward(Vec3f &) const
{ {
Q_ASSERT(0); Q_ASSERT(0);
return false; return false;
} }
bool StelProjector2d::backward(Vec3d &v) const bool StelProjector2d::backward(Vec3d &) const
{ {
Q_ASSERT(0); Q_ASSERT(0);
return false; return false;
} }
double StelProjector2d::fovToViewScalingFactor(double fov) const float StelProjector2d::fovToViewScalingFactor(float) const
{ {
return 1.; return 1.f;
} }
double StelProjector2d::viewScalingFactorToFov(double vsf) const float StelProjector2d::viewScalingFactorToFov(float) const
{ {
return 1.; return 1.f;
} }
double StelProjector2d::deltaZoom(double fov) const float StelProjector2d::deltaZoom(float fov) const
{ {
Q_ASSERT(0); Q_ASSERT(0);
return fov; return fov;
} }
 End of changes. 49 change blocks. 
58 lines changed or deleted 52 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/