mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
#3204 Add double precision to OffshoreSphericalCoords
This commit is contained in:
1 parent
92dd375da3
commit
9025cedecb
3 files changed
+22
-8
No files matched your search
@@ -43,9 +43,23 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float inc() const { return incAziR[0];}
|
explicit RiaOffshoreSphericalCoords(const cvf::Vec3d& vec)
|
||||||
float azi() const { return incAziR[1];}
|
{
|
||||||
float r() const { return incAziR[2];}
|
// 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.
|
// 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
|
// Todo: Convert class to a template to enable float and double versions of everything
|
||||||
@@ -57,6 +71,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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;
|
std::function<float (const RiaOffshoreSphericalCoords& )> operation;
|
||||||
if (resVarAddress.componentName == "Pazi")
|
if (resVarAddress.componentName == "Pazi")
|
||||||
{
|
{
|
||||||
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return sphCoord.azi();};
|
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.azi();};
|
||||||
}
|
}
|
||||||
else if ( resVarAddress.componentName == "Pinc" )
|
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)
|
#pragma omp parallel for schedule(dynamic)
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ TEST(RiaOffshoreSphericalCoords, RiaOffshoreSphericalCoords)
|
|||||||
cvf::Vec3f vec(1, 0, 0);
|
cvf::Vec3f vec(1, 0, 0);
|
||||||
RiaOffshoreSphericalCoords spCoord(vec);
|
RiaOffshoreSphericalCoords spCoord(vec);
|
||||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.inc()), 90.0, 1e-10);
|
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);
|
EXPECT_NEAR(spCoord.r(), 1.0, 1e-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ TEST(RiaOffshoreSphericalCoords, RiaOffshoreSphericalCoords)
|
|||||||
cvf::Vec3f vec(-1, 0, 0);
|
cvf::Vec3f vec(-1, 0, 0);
|
||||||
RiaOffshoreSphericalCoords spCoord(vec);
|
RiaOffshoreSphericalCoords spCoord(vec);
|
||||||
EXPECT_NEAR(cvf::Math::toDegrees(spCoord.inc()), 90.0, 1e-10);
|
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);
|
EXPECT_NEAR(spCoord.r(), 1.0, 1e-10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user