20 #ifndef _STELPROJECTIONS_HPP_
21 #define _STELPROJECTIONS_HPP_
23 #include "StelProjector.hpp"
36 const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
49 v[0] = std::numeric_limits<float>::max();
50 v[1] = std::numeric_limits<float>::max();
73 const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
74 const float f = std::sqrt(2.f/(r*(r-v[2])));
99 const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
100 const float h = 0.5f*(r-v[2]);
102 v[0] = std::numeric_limits<float>::max();
103 v[1] = std::numeric_limits<float>::max();
104 v[2] = -std::numeric_limits<float>::min();
107 const float f = 1.f / h;
114 virtual void project(
int n,
const Vec3d* in,
Vec3f* out)
117 for (
int i = 0; i < n; ++i, ++out)
120 modelViewTransform->forward(v);
121 out->set(v[0], v[1], v[2]);
123 out->set(viewportCenter[0] + flipHorz * pixelPerRad * (*out)[0],
124 viewportCenter[1] + flipVert * pixelPerRad * (*out)[1],
125 ((*out)[2] - zNear) * oneOverZNearMinusZFar);
148 const float rq1 = v[0]*v[0] + v[1]*v[1];
150 const float h = std::sqrt(rq1);
151 const float f = std::atan2(h,-v[2]) / h;
154 v[2] = std::sqrt(rq1 + v[2]*v[2]);
163 v[0] = std::numeric_limits<float>::max();
164 v[1] = std::numeric_limits<float>::max();
165 v[2] = std::numeric_limits<float>::min();
185 virtual void project(
int n,
const Vec3d* in,
Vec3f* out)
188 for (
int i = 0; i < n; ++i)
191 modelViewTransform->forward(v);
192 out[i].set(v[0], v[1], v[2]);
194 out[i][0] = viewportCenter[0] + flipHorz * pixelPerRad * out[i][0];
195 out[i][1] = viewportCenter[1] + flipVert * pixelPerRad * out[i][1];
196 out[i][2] = (out[i][2] - zNear) * oneOverZNearMinusZFar;
202 const float r = std::sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
203 const float alpha = std::atan2(v[0],-v[2]);
204 const float cosDelta = std::sqrt(1.f-v[1]*v[1]/(r*r));
205 float z = std::sqrt(1.+cosDelta*std::cos(alpha/2.f));
206 v[0] = 2.f*M_SQRT2*cosDelta*std::sin(alpha/2.f)/z;
207 v[1] = M_SQRT2*v[1]/r/z;
224 return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap3);
234 virtual float getMaxFov()
const {
return 175.f * 4.f/3.f;}
244 return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);
252 return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap2);
262 virtual float getMaxFov()
const {
return 175.f * 4.f/3.f;}
272 return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);
280 return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap2);
321 #endif // _STELPROJECTIONS_HPP_
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
bool forward(Vec3f &win) const
Apply the transformation in the forward direction in place.
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
bool forward(Vec3f &win) const
Apply the transformation in the forward direction in place.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
A SphericalCap is defined by a direction and an aperture.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
bool forward(Vec3f &win) const
Apply the transformation in the forward direction in place.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
bool forward(Vec3f &win) const
Apply the transformation in the forward direction in place.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
StelProjector(ModelViewTranformP amodelViewTransform)
Private constructor. Only StelCore can create instances of StelProjector.
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
Provide the main interface to all operations of projecting coordinates from sky to screen...
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual QString getNameI18() const
Get a human-readable name for this projection type.
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual void computeBoundingCap()
Initialize the bounding cap.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...