3d Movement with Origin and Vector (Angles)

Recommended Posts

josefnpat    101
I'm not a super math type, but I'm still interested in learning. I've been working on this game that I've been developing in blender, but I need some help on my php server end.

Basically, the server needs to calculate the next given location of a player.

My input is:
x,y,z and roll/pitch/yaw along with the distance travelled.

This is what I have so far, but I realised it's totally wrong. Was wondering if someone could help me out?
    $this->current_x =$this->current_x + $distance * cos(deg2rad($a)) * sin(deg2rad($z));$this->current_y = $this->current_y +$distance * sin(deg2rad($a)) * sin(deg2rad($z));    $this->current_z =$this->current_z + $distance * cos(deg2rad($z));

Share on other sites
josefnpat    101
Ok, so i found an example on some obscure forum. My final code ended up being:

    $a =$this->current_yaw;    $z = -$this->current_pitch;        // orig    $this->current_x +=$distance * cos(deg2rad($a)) * cos(deg2rad($z));    $this->current_y +=$distance * sin(deg2rad($a)) * cos(deg2rad($z));    $this->current_z +=$distance * sin(deg2rad(\$z));

Thought i'd share that with you all!