# Finding the position directly behind a player

by wolfknight
Tags: directly, player, position
 P: 5 I'm attempting SCIENCE by using math that I have never used before, nor do I understand (despite reading numerous articles, watching all of the khanacademy videos, etc etc) I'm attempting to use trig to locate a point directly behind another player in Minecraft. I've read through these three pages: http://stackoverflow.com/questions/4...-calculate-end http://en.wikipedia.org/wiki/Spheric...an_coordinates http://www.opentk.com/node/2505 and have come up with this code: double dEntityDistance = getPlayer().getDistanceToEntity(player); double dNewX = /* The current player */getPlayer().posX - dEntityDistance * Math.sin(Math.toRadians(/* The player we want the position behind */ player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch)); double dNewZ = getPlayer().posZ - dEntityDistance * Math.cos(Math.toRadians(player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch)); I know nothing about matrices (which some have suggested), nor do I know very much about trig. If anybody would be kind enough to explain a bit about those two subjects (or whichever one would help me with my problem), I would be very grateful.
 Mentor P: 10,846 Behind relative to what? The plane, or the direction the player is looking to? As a first step: Do you understand how Minecraft stores the orientation of the player? The definition of those parameters should give you a direct way to calculate x,y,z in front of the player. Behind is just the same, but with opposite signs for the distance. Comments directly in formulas? Really?
P: 5
 Quote by mfb the direction the player is looking to?
The direction the player is facing, yes, I apologize for not clarifying.

 Quote by mfb As a first step: Do you understand how Minecraft stores the orientation of the player?
I've been trying to find out for the last couple days. Notch and Jeb do it in a really really bad way, which is why I've been having loads of trouble.

 Quote by mfb Comments directly in formulas? Really?
Actually no, it's just that I was clarifying which entity was which.

P: 5

## Finding the position directly behind a player

I fixed this. Minecraft rotations are completely back-asswards, and it took me a while, but I now can successfully teleport behind other players.

 Related Discussions Biology 12 Calculus & Beyond Homework 1 Introductory Physics Homework 10 Introductory Physics Homework 2 General Discussion 13