StelProjectorClasses.hpp   StelProjectorClasses.hpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#ifndef _STELPROJECTIONS_HPP_ #ifndef _STELPROJECTIONS_HPP_
#define _STELPROJECTIONS_HPP_ #define _STELPROJECTIONS_HPP_
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include <limits>
class StelProjectorPerspective : public StelProjector class StelProjectorPerspective : public StelProjector
{ {
public: public:
StelProjectorPerspective(ModelViewTranformP func) : StelProjector(fu nc) {;} StelProjectorPerspective(ModelViewTranformP func) : StelProjector(fu nc) {;}
virtual QString getNameI18() const; virtual QString getNameI18() const;
virtual QString getDescriptionI18() const; virtual QString getDescriptionI18() const;
virtual float getMaxFov() const {return 120.f;} virtual float getMaxFov() const {return 120.f;}
bool forward(Vec3f &v) const bool forward(Vec3f &v) const;
{
const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
;
if (v[2] < 0) {
v[0] /= (-v[2]);
v[1] /= (-v[2]);
v[2] = r;
return true;
}
if (v[2] > 0) {
v[0] /= v[2];
v[1] /= v[2];
v[2] = r;
return false;
}
v[0] = std::numeric_limits<float>::max();
v[1] = std::numeric_limits<float>::max();
v[2] = r;
return false;
}
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return false;} virtual bool hasDiscontinuity() const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;}
}; };
class StelProjectorEqualArea : public StelProjector class StelProjectorEqualArea : public StelProjector
{ {
public: public:
StelProjectorEqualArea(ModelViewTranformP func) : StelProjector(func ) {;} StelProjectorEqualArea(ModelViewTranformP func) : StelProjector(func ) {;}
virtual QString getNameI18() const; virtual QString getNameI18() const;
virtual QString getDescriptionI18() const; virtual QString getDescriptionI18() const;
virtual float getMaxFov() const {return 360.f;} virtual float getMaxFov() const {return 360.f;}
bool forward(Vec3f &v) const bool forward(Vec3f &v) const;
{
const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
;
const float f = std::sqrt(2.f/(r*(r-v[2])));
v[0] *= f;
v[1] *= f;
v[2] = r;
return true;
}
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return false;} virtual bool hasDiscontinuity() const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;}
}; };
class StelProjectorStereographic : public StelProjector class StelProjectorStereographic : public StelProjector
{ {
public: public:
StelProjectorStereographic(ModelViewTranformP func) : StelProjector( func) {;} StelProjectorStereographic(ModelViewTranformP func) : StelProjector( func) {;}
virtual QString getNameI18() const; virtual QString getNameI18() const;
virtual QString getDescriptionI18() const; virtual QString getDescriptionI18() const;
virtual float getMaxFov() const {return 235.f;} virtual float getMaxFov() const {return 235.f;}
bool forward(Vec3f &v) const
{
const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
;
const float h = 0.5f*(r-v[2]);
if (h <= 0.f) {
v[0] = std::numeric_limits<float>::max();
v[1] = std::numeric_limits<float>::max();
v[2] = -std::numeric_limits<float>::min();
return false;
}
const float f = 1.f / h;
v[0] *= f;
v[1] *= f;
v[2] = r;
return true;
}
virtual void project(int n, const Vec3d* in, Vec3f* out) virtual void project(int n, const Vec3d* in, Vec3f* out)
{ {
Vec3d v; Vec3d v;
for (int i = 0; i < n; ++i, ++out) for (int i = 0; i < n; ++i, ++out)
{ {
v = in[i]; v = in[i];
modelViewTransform->forward(v); modelViewTransform->forward(v);
out->set(v[0], v[1], v[2]); out->set(v[0], v[1], v[2]);
StelProjectorStereographic::forward(*out); StelProjectorStereographic::forward(*out);
out->set(viewportCenter[0] + flipHorz * pixelPerRad * (*out)[0], out->set(viewportCenter[0] + flipHorz * pixelPerRad * (*out)[0],
viewportCenter[1] + flipVert * pixelPerRad * (*out)[1], viewportCenter[1] + flipVert * pixelPerRad * (*out)[1],
((*out)[2] - zNear) * oneOverZNearMinusZFar) ; ((*out)[2] - zNear) * oneOverZNearMinusZFar) ;
} }
} }
bool forward(Vec3f &v) const;
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return false;} virtual bool hasDiscontinuity() const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;}
}; };
class StelProjectorFisheye : public StelProjector class StelProjectorFisheye : public StelProjector
{ {
public: public:
StelProjectorFisheye(ModelViewTranformP func) : StelProjector(func) {;} StelProjectorFisheye(ModelViewTranformP func) : StelProjector(func) {;}
virtual QString getNameI18() const; virtual QString getNameI18() const;
virtual QString getDescriptionI18() const; virtual QString getDescriptionI18() const;
virtual float getMaxFov() const {return 180.00001f;} virtual float getMaxFov() const {return 180.00001f;}
bool forward(Vec3f &v) const bool forward(Vec3f &v) const;
{
const float rq1 = v[0]*v[0] + v[1]*v[1];
if (rq1 > 0.f) {
const float h = std::sqrt(rq1);
const float f = std::atan2(h,-v[2]) / h;
v[0] *= f;
v[1] *= f;
v[2] = std::sqrt(rq1 + v[2]*v[2]);
return true;
}
if (v[2] < 0.f) {
v[0] = 0.f;
v[1] = 0.f;
v[2] = 1.f;
return true;
}
v[0] = std::numeric_limits<float>::max();
v[1] = std::numeric_limits<float>::max();
v[2] = std::numeric_limits<float>::min();
return false;
}
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return false;} virtual bool hasDiscontinuity() const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;}
}; };
skipping to change at line 199 skipping to change at line 133
{ {
v = in[i]; v = in[i];
modelViewTransform->forward(v); modelViewTransform->forward(v);
out[i].set(v[0], v[1], v[2]); out[i].set(v[0], v[1], v[2]);
StelProjectorHammer::forward(out[i]); StelProjectorHammer::forward(out[i]);
out[i][0] = viewportCenter[0] + flipHorz * pixelPerR ad * out[i][0]; out[i][0] = viewportCenter[0] + flipHorz * pixelPerR ad * out[i][0];
out[i][1] = viewportCenter[1] + flipVert * pixelPerR ad * out[i][1]; out[i][1] = viewportCenter[1] + flipVert * pixelPerR ad * out[i][1];
out[i][2] = (out[i][2] - zNear) * oneOverZNearMinusZ Far; out[i][2] = (out[i][2] - zNear) * oneOverZNearMinusZ Far;
} }
} }
bool forward(Vec3f &v) const bool forward(Vec3f &v) const;
{
// Hammer Aitoff
const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
;
const float alpha = std::atan2(v[0],-v[2]);
const float cosDelta = std::sqrt(1.f-v[1]*v[1]/(r*r));
float z = std::sqrt(1.+cosDelta*std::cos(alpha/2.f));
v[0] = 2.f*M_SQRT2*cosDelta*std::sin(alpha/2.f)/z;
v[1] = M_SQRT2*v[1]/r/z;
v[2] = r;
return true;
}
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return true;} virtual bool hasDiscontinuity() const {return true;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const {return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);} virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const {return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d& cap N, double capD) const virtual bool intersectViewportDiscontinuityInternal(const Vec3d& cap N, double capD) const
{ {
static const SphericalCap cap1(1,0,0); static const SphericalCap cap1(1,0,0);
skipping to change at line 302 skipping to change at line 225
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
float viewScalingFactorToFov(float vsf) const; float viewScalingFactorToFov(float vsf) const;
float deltaZoom(float fov) const; float deltaZoom(float fov) const;
protected: protected:
virtual bool hasDiscontinuity() const {return false;} virtual bool hasDiscontinuity() const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, co nst Vec3d&) const {return false;}
virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;} virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, do uble) const {return false;}
}; };
class StelProjectorSinusoidal : public StelProjectorCylinder
{
public:
StelProjectorSinusoidal(ModelViewTranformP func) : StelProjectorCyli
nder(func) {;}
virtual QString getNameI18() const;
virtual QString getDescriptionI18() const;
bool forward(Vec3f &win) const;
bool backward(Vec3d &v) const;
};
class StelProjector2d : public StelProjector class StelProjector2d : public StelProjector
{ {
public: public:
StelProjector2d() : StelProjector(ModelViewTranformP(new StelProject or::Mat4dTransform(Mat4d::identity()))) {;} StelProjector2d() : StelProjector(ModelViewTranformP(new StelProject or::Mat4dTransform(Mat4d::identity()))) {;}
virtual QString getNameI18() const; virtual QString getNameI18() const;
virtual QString getDescriptionI18() const; virtual QString getDescriptionI18() const;
virtual float getMaxFov() const {return 360.f;} virtual float getMaxFov() const {return 360.f;}
bool forward(Vec3f &win) const; bool forward(Vec3f &win) const;
bool backward(Vec3d &v) const; bool backward(Vec3d &v) const;
float fovToViewScalingFactor(float fov) const; float fovToViewScalingFactor(float fov) const;
 End of changes. 8 change blocks. 
86 lines changed or deleted 16 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/