Public Function Translate3D2D(ByVal X As Single, ByVal Y As Single, ByVal Z As Single) As POINTAPI
'POINTAPI is just a UDT with X and Y (both single) members
Dim Ret As POINTAPI
Dim dx As Single, dy As Single, dz As Single
Dim Ax As Single, Ay As Single, Dist As Single
dx = X - mcamCamera.X
dy = Y - mcamCamera.Y
dz = Z - mcamCamera.Z
'Ax is the horizontal angle between the cam heading and the point
Ax = mcamCamera.Heading - (Atn(dx / dz) + 180) 'probably wrong
'dist is the horizontal distance (xy plane)
Dist = Sqr((dx * dx) + (dy * dy))
'Ay is the vertical angle between the cam elevation and the point
Ay = mcamCamera.Elev - Atn(dy / Dist) 'probably wrong
'convert these angles into screen coordinates
Ret.X = (mcamCamera.ZDist * Tan(Ax))'probably wrong
Ret.Y = (mcamCamera.ZDist * Tan(Ay))'probably wrong
Translate3D2D = Ret 'pass results back to the calling procedure
End Function