mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include "cvfVector3.h"
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
// Y - North, X - East, Z - up but depth is negative Z
|
||||
@@ -31,49 +31,61 @@ const double singularityEpsilon = 1.0e-5;
|
||||
class RiaOffshoreSphericalCoords
|
||||
{
|
||||
public:
|
||||
explicit RiaOffshoreSphericalCoords(const cvf::Vec3f& vec)
|
||||
explicit RiaOffshoreSphericalCoords( const cvf::Vec3f& vec )
|
||||
{
|
||||
// Azimuth:
|
||||
if ( fabs(vec[0]) < singularityEpsilon && fabs(vec[1]) < singularityEpsilon ) incAziR[1] = 0.0f;
|
||||
else incAziR[1] = atan2(vec[0], vec[1]); // atan2(Y, X)
|
||||
// Azimuth:
|
||||
if ( fabs( vec[0] ) < singularityEpsilon && fabs( vec[1] ) < singularityEpsilon )
|
||||
incAziR[1] = 0.0f;
|
||||
else
|
||||
incAziR[1] = atan2( vec[0], vec[1] ); // atan2(Y, X)
|
||||
|
||||
// R
|
||||
incAziR[2] = vec.length();
|
||||
|
||||
// Inclination from vertical down
|
||||
if (fabs( incAziR[2]) < singularityEpsilon) incAziR[0] = 0.0f;
|
||||
else incAziR[0] = acos(-vec[2]/incAziR[2]);
|
||||
|
||||
if ( fabs( incAziR[2] ) < singularityEpsilon )
|
||||
incAziR[0] = 0.0f;
|
||||
else
|
||||
incAziR[0] = acos( -vec[2] / incAziR[2] );
|
||||
}
|
||||
|
||||
explicit RiaOffshoreSphericalCoords(const cvf::Vec3d& vec)
|
||||
explicit RiaOffshoreSphericalCoords( const cvf::Vec3d& vec )
|
||||
{
|
||||
// Azimuth:
|
||||
if (fabs(vec[0]) < singularityEpsilon && fabs(vec[1]) < singularityEpsilon ) incAziR[1] = 0.0;
|
||||
else incAziR[1] = atan2(vec[0], vec[1]); // atan2(Y, X)
|
||||
// Azimuth:
|
||||
if ( fabs( vec[0] ) < singularityEpsilon && fabs( vec[1] ) < singularityEpsilon )
|
||||
incAziR[1] = 0.0;
|
||||
else
|
||||
incAziR[1] = atan2( vec[0], vec[1] ); // atan2(Y, X)
|
||||
|
||||
// R
|
||||
// R
|
||||
incAziR[2] = vec.length();
|
||||
|
||||
// Inclination from vertical down
|
||||
if (fabs( incAziR[2]) < singularityEpsilon) incAziR[0] = 0.0;
|
||||
else incAziR[0] = acos(-vec[2]/incAziR[2]);
|
||||
|
||||
if ( fabs( incAziR[2] ) < singularityEpsilon )
|
||||
incAziR[0] = 0.0;
|
||||
else
|
||||
incAziR[0] = acos( -vec[2] / incAziR[2] );
|
||||
}
|
||||
double inc() const
|
||||
{
|
||||
return incAziR[0];
|
||||
}
|
||||
double azi() const
|
||||
{
|
||||
return incAziR[1];
|
||||
}
|
||||
double r() const
|
||||
{
|
||||
return incAziR[2];
|
||||
}
|
||||
double inc() const { return incAziR[0];}
|
||||
double azi() const { return incAziR[1];}
|
||||
double r() const { return incAziR[2];}
|
||||
|
||||
// Note that this is a double function, while the rest of the class is float.
|
||||
// Todo: Convert class to a template to enable float and double versions of everything
|
||||
static cvf::Vec3d unitVectorFromAziInc(double azimuth, double inclination)
|
||||
static cvf::Vec3d unitVectorFromAziInc( double azimuth, double inclination )
|
||||
{
|
||||
return cvf::Vec3d(sin(azimuth)*sin(inclination),
|
||||
cos(azimuth)*sin(inclination),
|
||||
-cos(inclination));
|
||||
return cvf::Vec3d( sin( azimuth ) * sin( inclination ), cos( azimuth ) * sin( inclination ), -cos( inclination ) );
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<double, 3> incAziR;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user