Skip to content

Commit

Permalink
Expose method on AR Utils that takes in an ENU coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jan 1, 2024
1 parent 8a207d1 commit 4e55903
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,43 @@ object AugmentedRealityUtils {
): PixelCoordinate {
val d = distance.coerceIn(minDistance, maxDistance)

// Negate the rotation of the device
val world = toArSpace(bearing, elevation, d, rotationMatrix)
return getPixel(
toEastNorthUp(bearing, elevation, d),
rotationMatrix,
rect,
fov,
mapperOverride
)
}

/**
* Gets the pixel coordinate of a point in the ENU coordinate system.
* @param enuCoordinate The ENU coordinate of the point
* @param rotationMatrix The rotation matrix of the device in the AR coordinate system
* @param rect The rectangle of the view in pixels
* @param fov The field of view of the camera in degrees
* @param mapperOverride A mapper to override the default mapper
* @return The pixel coordinate
*/
fun getPixel(
enuCoordinate: Vector3,
rotationMatrix: FloatArray,
rect: RectF,
fov: Size,
mapperOverride: CameraAnglePixelMapper? = null
): PixelCoordinate {
val mapper = mapperOverride ?: defaultMapper

val world = enuToAr(enuCoordinate, rotationMatrix)

return mapper.getPixel(
world,
rect,
fov
)
}


/**
* Computes the orientation of the device in the AR coordinate system.
* @param orientationSensor The orientation sensor
Expand Down

0 comments on commit 4e55903

Please sign in to comment.