mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-03 20:20:48 -06:00
#3204 Add double precision to OffshoreSphericalCoords
This commit is contained in:
parent
92dd375da3
commit
9025cedecb
@ -43,9 +43,23 @@ public:
|
||||
|
||||
}
|
||||
|
||||
float inc() const { return incAziR[0];}
|
||||
float azi() const { return incAziR[1];}
|
||||
float r() const { return incAziR[2];}
|
||||
explicit RiaOffshoreSphericalCoords(const cvf::Vec3d& vec)
|
||||
{
|
||||
// Azimuth:
|
||||
if (vec[0] == 0.0 && vec[1] == 0.0 ) incAziR[1] = 0.0;
|
||||
else incAziR[1] = atan2(vec[0], vec[1]); // atan2(Y, X)
|
||||
|
||||
// R
|
||||
incAziR[2] = vec.length();
|
||||
|
||||
// Inclination from vertical down
|
||||
if (incAziR[2] == 0) 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];}
|
||||
|
||||
// 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
|
||||
@ -57,6 +71,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<float, 3> incAziR;
|
||||
std::array<double, 3> incAziR;
|
||||
};
|
||||
|
||||
|
@ -441,11 +441,11 @@ void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(cvf::Vec2fArray* t
|
||||
std::function<float (const RiaOffshoreSphericalCoords& )> operation;
|
||||
if (resVarAddress.componentName == "Pazi")
|
||||
{
|
||||
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return sphCoord.azi();};
|
||||
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.azi();};
|
||||
}
|
||||
else if ( resVarAddress.componentName == "Pinc" )
|
||||
{
|
||||
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return sphCoord.inc();};
|
||||
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.inc();};
|
||||
}
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
|
@ -117,7 +117,7 @@ TEST(RiaOffshoreSphericalCoords, RiaOffshoreSphericalCoords)
|
||||
cvf::Vec3f vec(1, 0, 0);
|
||||
RiaOffshoreSphericalCoords spCoord(vec);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.inc()), 90.0, 1e-10);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.azi()), 90.0, 1e-10);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.azi()), 90.0, 1e-5);
|
||||
EXPECT_NEAR(spCoord.r(), 1.0, 1e-10);
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ TEST(RiaOffshoreSphericalCoords, RiaOffshoreSphericalCoords)
|
||||
cvf::Vec3f vec(-1, 0, 0);
|
||||
RiaOffshoreSphericalCoords spCoord(vec);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.inc()), 90.0, 1e-10);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.azi()), -90.0, 1e-10);
|
||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.azi()), -90.0, 1e-5);
|
||||
EXPECT_NEAR(spCoord.r(), 1.0, 1e-10);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user