How expensive are rays?

I'm using a second camera that doesn't render and mounted to the nose of my ship as a sort of radar for my HUD, using getScreenCoordinates. The problem is that it seems kind of laggy in that the target icons don't match the position of the objects exactly. I'm thinking it has something to do with the distance and perspective of the camera to the HUD mount in my virtual cockpit.

Anyway, I'm contemplating just casting a ray from the camera and reading where it intersects the HUD and then plopping an icon at that position. My concern is with a bunch of targets will this be a big performance drag? Is it more or less efficient than calling getScreenCoords for each target?

Many thanks!

getScreenCoords() just does a bit of math, while rays intersection parses the whole scenegraph discard non-intersecting Nodes and Spatials. So getScreenCoords() should be much faster than rays.

The best solution is to write custom code to map 3d positions of your targets onto your hood.

I assume you are dealing with space-ships and not naval ships (for naval ships you could just use 2d positions of targets for the radar).

Typical radars for flying games are showing all the objects in front and all the objects behind. They use spherical mapping. You could easily do the spherical mapping as follows:

Take a vector T between the target and your plane.

Project T onto the plane(direction, up) of your craft.

Find the angle V between the projection and the up vector.

Project T onto the plane(direction, left) of your craft.

Find the angle H between the projection and the left vector.

Draw the target onto your radar using (H, V) as 2d coordinates.