Skip to content

Commit

Permalink
Rename spherical to cartesian method for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jan 1, 2024
1 parent fabd440 commit 03dea0c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ object AugmentedRealityUtils {
}

/**
* Converts a spherical coordinate to a cartesian coordinate in the AR coordinate system.
* Converts a spherical coordinate to a cartesian coordinate in the East-North-Up (ENU) coordinate system.
* @param bearing The azimuth in degrees (rotation around the z axis)
* @param elevation The elevation in degrees (rotation around the x axis)
* @param distance The distance in meters
*/
private fun toWorldCoordinate(
private fun toEastNorthUp(
bearing: Float,
elevation: Float,
distance: Float
Expand All @@ -164,9 +164,9 @@ object AugmentedRealityUtils {
val phiRad = bearing.toRadians()

val cosTheta = cos(thetaRad)
val x = distance * cosTheta * sin(phiRad)
val y = distance * cosTheta * cos(phiRad)
val z = distance * sin(thetaRad)
val x = distance * cosTheta * sin(phiRad) // East
val y = distance * cosTheta * cos(phiRad) // North
val z = distance * sin(thetaRad) // Up
return Vector3(x, y, z)
}

Expand All @@ -188,7 +188,7 @@ object AugmentedRealityUtils {
rotationMatrix: FloatArray
): Pair<Float, Float> {
// Convert to world space
val worldVector = toWorldCoordinate(bearing, elevation, distance)
val worldVector = toEastNorthUp(bearing, elevation, distance)

// Rotate
val rotated = synchronized(worldVectorLock) {
Expand Down

0 comments on commit 03dea0c

Please sign in to comment.