| 49 | } |
| 50 | |
| 51 | glm::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 | |
| 84 | SimplePlanarEllipsoidCurve::SimplePlanarEllipsoidCurve( |
| 85 | const Ellipsoid& ellipsoid, |
no test coverage detected