The correct way of finding bearing elevation. (distance part was right). This is relative to the chip's forward vector.
Code:
N@Bearing
I@Xt Yt Zt
O@Bearing Elevation Dist
interval(1)
Target=vecsub(vector(Xt,Yt, Zt),extpos())
TargetN=vecnormalize(Target)
Br=acos(vecdot(extdirfw(),TargetN)/(veclength(extdirfw())*veclenght(TargetN)))
En=acos(vecdot(extdirup(),TargetN)/(veclength(extdirup())*veclenght(TargetN)))-90
Trt=acos(vecdot(extdirrt(),TargetN)/(veclength(extdirrt())*veclenght(TargetN)))
Tr=angnorm(Trt-90)
Bearing=(Br>0&Br<181?Br*sgn(Tr):0)
Elevation=En
Dist=veclength(Target)
The reason I post this here was I made a turret using the idea you had here, to do everything with vectors. However, that didn't work when the turret was tilted. So, with this, it will work right. Have fun.
Bookmarks