SVN commit 1224498 by khudyakov: Add function to convert from sherical coordinates to cartesian. Function itself isn't used anywhere yet but this pattern appears in lot of places in the code. CCMAIL: kstars-devel@kde.org M +12 -0 ksutils.h --- trunk/KDE/kdeedu/kstars/kstars/ksutils.h #1224497:1224498 @@ -30,6 +30,7 @@ #include USING_PART_OF_NAMESPACE_EIGEN #include +#include "dms.h" class QFile; class QString; @@ -73,6 +74,17 @@ return x - delta*floor( (x-min)/delta ); } + /** Convert from spherical to cartesian coordiate system. + * Resulting vector have unit length + */ + inline Vector3d fromSperical(dms longitude, dms latitude) { + double sinL, sinB; + double cosL, cosB; + longitude.SinCos( sinL, cosL ); + latitude.SinCos( sinB, cosB ); + return Vector3d(cosB*cosL, cosB*sinL, sinB); + } + /** Convert a vector to a point */ inline QPointF vecToPoint(const Vector2f& vec) { return QPointF( vec[0], vec[1] );