Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SphericalTransform Class Reference

#include <nonlinear_transform.h>

Inheritance diagram for SphericalTransform:
IdentityTransform

Public Member Functions

 SphericalTransform (float a, float b, float c)
 
void SetXZ (float x, float z)
 
void SetR (float rr)
 
float GetR () const
 
float GetX () const
 
float GetZ () const
 
QVector Transform (const QVector &v) const
 Transforms in a possibly nonlinear way the point to some new space. More...
 
QVector TransformNormal (const QVector &point, const QVector &n) const
 transforms a direction to some new space More...
 
QVector InvTransform (const QVector &v) const
 Transforms in reverse the vector into quadsquare space. More...
 
CLIPSTATE BoxInFrustum (Vector &min, Vector &max, const Vector &campos) const
 Transforms a min and a max vector and figures out what is bigger. More...
 
- Public Member Functions inherited from IdentityTransform
float TransformS (float x, float scale) const
 
float TransformT (float y, float scale) const
 

Protected Attributes

float scalex
 
float scalez
 
float r
 

Detailed Description

Definition at line 46 of file nonlinear_transform.h.

Constructor & Destructor Documentation

SphericalTransform::SphericalTransform ( float  a,
float  b,
float  c 
)
inline

Definition at line 50 of file nonlinear_transform.h.

References SetR(), and SetXZ().

50  : SphericalTransform( float a, float b, float c ) : IdentityTransform()
51  {
52  SetXZ( a, c );
53  SetR( b );
54  }

Member Function Documentation

CLIPSTATE SphericalTransform::BoxInFrustum ( Vector min,
Vector max,
const Vector campos 
) const
inlinevirtual

Transforms a min and a max vector and figures out what is bigger.

Reimplemented from IdentityTransform.

Definition at line 92 of file nonlinear_transform.h.

References GFX_PARTIALLY_VISIBLE, GFXSpherePartiallyInFrustum(), Magnitude(), SphereTransformRenderlevel, Transform(), and Vector.

93  {
94  const float rendermin = 3;
95  /*
96  * float tmpx = fabs(campos.i-min.i);float maxx = fabs(campos.i-max.i);
97  * if (tmpx>.35*GetX()&&tmpx<.65*GetX()&&maxx>.25*GetX()&&maxx<.75*GetX()) {return GFX_NOT_VISIBLE;}
98  * tmpx = fabs(campos.k-min.k); maxx = fabs(campos.k-max.k);
99  * if (tmpx>.25*GetZ()&&tmpx<.75*GetZ()&&maxx>.25*GetZ()&&maxx<.75*GetZ()) { return GFX_NOT_VISIBLE;//i/f it's on the other side of the hemisphere} */
100  if (SphereTransformRenderlevel < rendermin)
101  return GFX_PARTIALLY_VISIBLE;
104  tmax = .5*(tmax+tmin); //center
105  float rad = 1.8*(tmax-tmin).Magnitude();
106 
107  return GFXSpherePartiallyInFrustum( tmax, rad );
108  }
float SphericalTransform::GetR ( ) const
inline

Definition at line 64 of file nonlinear_transform.h.

References r.

65  {
66  return r;
67  }
float SphericalTransform::GetX ( ) const
inline

Definition at line 68 of file nonlinear_transform.h.

References M_PI, and scalex.

69  {
70  return 2*M_PI/scalex;
71  }
float SphericalTransform::GetZ ( ) const
inline

Definition at line 72 of file nonlinear_transform.h.

References M_PI, and scalez.

73  {
74  return M_PI/scalez;
75  }
QVector SphericalTransform::InvTransform ( const QVector v) const
inlinevirtual

Transforms in reverse the vector into quadsquare space.

Reimplemented from IdentityTransform.

Definition at line 86 of file nonlinear_transform.h.

References UniverseUtil::asin(), M_PI, QVector, r, scalex, and scalez.

87  {
88  float rplusy = v.Magnitude();
89  //float lengthxypln = sqrtf (rplusy*rplusy-v.j*v.j);//pythagorus
90  return QVector( (atan2( -v.k, -v.i )+M_PI)/scalex, rplusy-r, (asin( v.j/rplusy )+M_PI*.5)/scalez );
91  }
void SphericalTransform::SetR ( float  rr)
inline

Definition at line 60 of file nonlinear_transform.h.

References r.

Referenced by SphericalTransform().

61  {
62  r = rr;
63  }
void SphericalTransform::SetXZ ( float  x,
float  z 
)
inline

Definition at line 55 of file nonlinear_transform.h.

References M_PI, scalex, scalez, and x.

Referenced by SphericalTransform().

56  {
57  this->scalex = 2*M_PI/x;
58  this->scalez = M_PI/z;
59  } //x ranges from 0 to 2PI x ranges from -PI/2 to PI/2
QVector SphericalTransform::Transform ( const QVector v) const
inlinevirtual

Transforms in a possibly nonlinear way the point to some new space.

Reimplemented from IdentityTransform.

Definition at line 76 of file nonlinear_transform.h.

References UniverseUtil::cos(), M_PI, QVector, r, scalex, scalez, UniverseUtil::sin(), and Vector.

Referenced by BoxInFrustum(), and TransformNormal().

77  {
78  Vector T( v.i*scalex, r+v.j, v.k*scalez-.5*M_PI );
79  float cosphi = cos( T.k );
80  return QVector( T.j*cosphi*cos( T.i ), T.j*sin( T.k ), T.j*cosphi*sin( T.i ) );
81  }
QVector SphericalTransform::TransformNormal ( const QVector v,
const QVector n 
) const
inlinevirtual

transforms a direction to some new space

Reimplemented from IdentityTransform.

Definition at line 82 of file nonlinear_transform.h.

References Transform().

83  {
84  return SphericalTransform::Transform( n+point )-Transform( point );
85  }

Member Data Documentation

float SphericalTransform::r
protected

Definition at line 49 of file nonlinear_transform.h.

Referenced by GetR(), InvTransform(), SetR(), and Transform().

float SphericalTransform::scalex
protected

Definition at line 49 of file nonlinear_transform.h.

Referenced by GetX(), InvTransform(), SetXZ(), and Transform().

float SphericalTransform::scalez
protected

Definition at line 49 of file nonlinear_transform.h.

Referenced by GetZ(), InvTransform(), SetXZ(), and Transform().


The documentation for this class was generated from the following file: