MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / getPosition

Method getPosition

CesiumGeospatial/src/SimplePlanarEllipsoidCurve.cpp:51–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51glm::dvec3 SimplePlanarEllipsoidCurve::getPosition(
52 double percentage,
53 double additionalHeight) const {
54 if (percentage <= 0.0) {
55 return this->_sourceEcef;
56 } else if (percentage >= 1.0) {
57 // We can shortcut our math here and just return the destination.
58 return this->_destinationEcef;
59 }
60
61 percentage = glm::clamp(percentage, 0.0, 1.0);
62
63 // Rotate us around the circle between points A and B by the given percentage
64 // of the total angle we're rotating by.
65 glm::dvec3 rotatedDirection =
66 glm::angleAxis(percentage * this->_totalAngle, this->_rotationAxis) *
67 this->_sourceDirection;
68
69 // It's safe for us to assume here that scaleToGeocentricSurface will return a
70 // value, since rotatedDirection should never be (0, 0, 0)
71 glm::dvec3 geocentricPosition =
72 this->_ellipsoid.scaleToGeocentricSurface(rotatedDirection)
73 .value_or(glm::dvec3(0, 0, 0));
74
75 glm::dvec3 geocentricUp = glm::normalize(geocentricPosition);
76
77 double altitudeOffset =
78 glm::mix(this->_sourceHeight, this->_destinationHeight, percentage) +
79 additionalHeight;
80
81 return geocentricPosition + geocentricUp * altitudeOffset;
82}
83
84SimplePlanarEllipsoidCurve::SimplePlanarEllipsoidCurve(
85 const Ellipsoid& ellipsoid,

Calls 3

clampFunction · 0.85
normalizeFunction · 0.85

Tested by

no test coverage detected