Topic has a solution
Topic solved

Hello,
I'm working on an AR application using Vuforia engine.

For an arbitrary AR camera position and rotation, I want to determine whether a moving target is visible or off-camera.
And if the target is off-camera, I want to display an arrow on the UI canvas indicating the direction the target is in.

After the image marker is detected, the following values are available.
(1) ARCamera's position and rotation values (6 values)
(2) The target object's position values (3 values)

I noticed that all these values are based on the marker position.
In other words, the "world coordinate system" in this context is the "marker coordinate system".

Now how can I get the target object direction vector?

I think I need to first convert the target object's marker coordinate values to camera coordinate values.
Then, I need to do some calculations to determine if the target is visible or not for a given camera FOV (horizontal/vertical).

I'm not used to handling Unity classes and functions for this kind of matrix calculation.
Could you help me out?

I have attached two images showing my task.

AttachmentSize
71.85 KB
49.62 KB
Platform:

Hi Patrick,

In the meantime, I figured out the following solution myself.

public class Arrow : MonoBehaviour

{

public GameObject arrowTarget;

public GameObject arrow;

private Vector3 targetWorldCoordinate, targetCameraCoordinate;

private float horAngle, verAngle;

void Update()

{

targetWorldCoordinate = arrowTarget.transform.position;

targetCameraCoordinate = transform.worldToLocalMatrix * (targetWorldCoordinate - transform.position);

horAngle = Mathf.Atan2(targetCameraCoordinate.x, targetCameraCoordinate.z) * Mathf.Rad2Deg;

verAngle = Mathf.Atan2(targetCameraCoordinate.y, targetCameraCoordinate.z) * Mathf.Rad2Deg;

float arrowAngle = Mathf.Atan2(verAngle, horAngle) * Mathf.Rad2Deg;

arrow.transform.rotation = Quaternion.Euler(0, 0, arrowAngle);

}

}

Hey there,

I think you can circumvent this issue by changing the World Center Mode: https://developer.vuforia.com/forum/unity-extension-technical-discussion/what-world-center-mode#comment-47076

Kind regards,

Patrick Scheper

Vuforia Engine Product Manager