MCPcopy Create free account
hub / github.com/comaps/comaps / GetPointOnSphere

Function GetPointOnSphere

libs/geometry/area_on_earth.cpp:19–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17double constexpr kEarthRadiusMetersSquared = kEarthRadiusMeters * kEarthRadiusMeters;
18
19m3::PointD GetPointOnSphere(LatLon const & ll, double sphereRadius)
20{
21 ASSERT(LatLon::kMinLat <= ll.m_lat && ll.m_lat <= LatLon::kMaxLat, (ll));
22 ASSERT(LatLon::kMinLon <= ll.m_lon && ll.m_lon <= LatLon::kMaxLon, (ll));
23
24 double const latRad = math::DegToRad(ll.m_lat);
25 double const lonRad = math::DegToRad(ll.m_lon);
26
27 double const x = sphereRadius * cos(latRad) * cos(lonRad);
28 double const y = sphereRadius * cos(latRad) * sin(lonRad);
29 double const z = sphereRadius * sin(latRad);
30
31 return {x, y, z};
32}
33} // namespace
34
35// Look to https://en.wikipedia.org/wiki/Solid_angle for more details.

Callers 1

AreaOnEarthFunction · 0.85

Calls 2

ASSERTFunction · 0.85
DegToRadFunction · 0.85

Tested by

no test coverage detected