# Finding the position directly behind a player

• wolfknight
In summary, the conversation discusses the use of trigonometry and matrices to locate a point directly behind another player in Minecraft. The individual has researched and consulted various sources, including code examples, in order to come up with a solution. They also mention the difficulty in understanding how Minecraft stores the orientation of players and the challenges it presents. Ultimately, they have successfully figured out how to teleport behind other players using this method.
wolfknight
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/...rotational-axis-and-a-direction-calculate-end
http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
http://www.opentk.com/node/2505

and have come up with this code:

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.

Last edited by a moderator:
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.

mfb said:
the direction the player is looking to?
The direction the player is facing, yes, I apologize for not clarifying.

mfb said:
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.

mfb said:
Actually no, it's just that I was clarifying which entity was which.

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

## 1. How do you determine the exact position behind a player?

To determine the exact position behind a player, you will need to use a combination of spatial awareness, distance measurements, and angles. This can be done through various methods such as using a tracking system or manually measuring distances and angles.

## 2. Why is finding the position directly behind a player important?

Finding the position directly behind a player is important in sports and other physical activities as it allows for strategic positioning and better control of the game. It also helps in avoiding blind spots and maximizing the use of available space on the field.

## 3. Can you find the position directly behind a player in real-time?

Yes, it is possible to find the position directly behind a player in real-time using advanced tracking technology and algorithms. This allows for quick decision-making and adjustments during a game or activity.

## 4. What factors can affect the accuracy of finding the position directly behind a player?

The accuracy of finding the position directly behind a player can be affected by various factors such as the quality of tracking technology, lighting conditions, and the speed and movement of the players. Human error and technical issues can also impact the accuracy of the results.

## 5. How can finding the position directly behind a player benefit sports teams and athletes?

Finding the position directly behind a player can benefit sports teams and athletes by providing them with valuable information about their opponents' movements and positioning. This can help in creating effective game strategies, improving team coordination, and enhancing individual performance.