math programing
Blitz3D Forums/Blitz3D Programming/math programing
| ||
Hey guys, I'm not a huge math guy. I need to make a "manual" alignToVector function. "manual" meaning it uses just math instead of blitz's entity system. It needs to take a vector and pump out Pitch and Yaw values. how do I do this? |
| ||
The tangent commands like Atan2 are your friends here... Im bad with efficient math, so I wont bother writing a slow routine for you, but im sure someone here is able to do so. |
| ||
Unverified - but it looks about right:Function Point_Entity(entity,x#,y#,z#) xdiff# = EntityX(entity)-x# ydiff# = EntityY(entity)-y# zdiff# = EntityZ(entity)-z# dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#)) pitch# = ATan2(ydiff#,dist#) yaw# = ATan2(xdiff#,-zdiff#) RotateEntity entity,pitch#,yaw#,0 End Function |