Commit ca1ed527 authored by Stefan Philips's avatar Stefan Philips
Browse files

[ADD] Function setEuclidean to WUnitSphereCoordinates

parent a2f66019
......@@ -55,7 +55,7 @@ public:
* Constructor for Euclidean coordinates.
* \param vector Euclidean coordinates
*/
explicit WUnitSphereCoordinates( WMatrixFixed< T, 3, 1 > vector );
explicit WUnitSphereCoordinates( const WMatrixFixed< T, 3, 1 >& vector );
/**
* Destructor.
......@@ -95,6 +95,13 @@ public:
*/
WMatrixFixed< T, 3, 1 > getEuclidean() const;
/**
* Returns the stored sphere coordinates as Euclidean coordinates.
*
* \param sphere coordinates in euclidean space
*/
void setEuclidean( WMatrixFixed< T, 3, 1 > );
protected:
private:
/** coordinate */
......@@ -118,12 +125,9 @@ WUnitSphereCoordinates< T >::WUnitSphereCoordinates( T theta, T phi )
}
template< typename T >
WUnitSphereCoordinates< T >::WUnitSphereCoordinates( WMatrixFixed< T, 3, 1 > vector )
WUnitSphereCoordinates< T >::WUnitSphereCoordinates( const WMatrixFixed< T, 3, 1 >& vector )
{
vector = normalize( vector );
// calculate angles
m_theta = std::acos( vector[2] );
m_phi = std::atan2( vector[1], vector[0] );
setEuclidean( vector );
}
template< typename T >
......@@ -161,4 +165,13 @@ WMatrixFixed< T, 3, 1 > WUnitSphereCoordinates< T >::getEuclidean() const
return WMatrixFixed< T, 3, 1 >( std::sin( m_theta )*std::cos( m_phi ), std::sin( m_theta )*std::sin( m_phi ), std::cos( m_theta ) );
}
template< typename T >
void WUnitSphereCoordinates< T >::setEuclidean( WMatrixFixed< T, 3, 1 > vector )
{
vector = normalize( vector );
// calculate angles
m_theta = std::acos( vector[2] );
m_phi = std::atan2( vector[1], vector[0] );
}
#endif // WUNITSPHERECOORDINATES_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment