# Math Help - Angle and Offset

1. ## Angle and Offset

Hi,
I am new to this forum, and I hope I am posting this in the right section.

I am working on some code for some game, and I got stuck on a mathematical problem.

I have a point ( in the image Point A) Where of I have this information:
X, Y and Z coordinates
Yaw, Pitch and Roll

What I want to do is to calculate the X Y and Z coordinates of point B.
The information I have about point B is an offset from point A.
This offset is in the direction of the angles Yaw Pitch and Roll.

An Image which hopefully makes my question totally clear.

Does somebody know how to calculate the coordinates of point B?

If anything isn't totally clear, please tell what it is. As I am Dutch, I'm not so good at describing my issue.

2. ## Re: Angle and Offset

This is 3D vector problem.

You haven't provided enough information to solve this problem. Can you explain how the Yaw Pitch and Roll angles measured around these axes will tell you where "B" is? If "B" is purely dictated by an angle from these axes (Pitch Roll and Yaw), There will be a whole series of points along a straight line that satisfy this condition, so "B" will not be a single point. You also need a distance from A to B.

Imagine attaching a string to the bottom corner of a room (where 2 walls meet the floor, so this is like x, y, and z axes at point A), and attaching the other end to something in the room (like a tv or something). The angles between any point along the string (point B), and the corners of the room (the axes), stay exactly the same. This means you can pick any point along the string, and the Yaw, pitch, and roll from A to that point are equal. Therefore, point B is variable unless you have a distance from A as well.

Please visit Facebook and Private maths tuition UK, online maths tuition UK, GCSE maths tuition UK to support us

3. ## Re: Angle and Offset

This is the exact situation:
Point A is the precise center of a car. Point B is the position of the car's petrol cap.
Coordinates of the car are given as X Y Z, and the rotation of the car is given as yaw pitch and roll.
I know, for example, that the offset to the petrol cap is 0.8, -1.2, -0.2 is, so 0.8 coordinates (from the car's center) to the car's right, 1.2 throwards the car's back, and 0.2 to the car's bottom.
With that information it should be possible (with sine and cosine) to calculate the coordinates of the petrol cap. But i don't know how..

I hope this makes my question totally clear

4. ## Re: Angle and Offset

This is a case of successive rotations...so order of the 3 rotations is to be maintained.
Assuming that rotations occur successively 1) gamma around z , 2) beta around y, 3) alpha around x...coordinates of points in the new rotated and translated system are {X, Y, Z} according to the following r-t equations:

$\left(\begin{array}{c} X_B \\ Y_B \\ Z_B\end{array}\right)\text{:=}\left(\begin{array}{ ccc} \cos (\beta ) \cos (\gamma ) & \sin (\alpha ) \sin (\beta ) \cos (\gamma )-\cos (\alpha ) \sin (\gamma ) & \cos (\alpha ) \sin (\beta ) \cos (\gamma )+\sin (\alpha ) \sin (\gamma ) \\ \cos (\beta ) \sin (\gamma ) & \sin (\alpha ) \sin (\beta ) \sin (\gamma )+\cos (\alpha ) \cos (\gamma ) & \cos (\alpha ) \sin (\beta ) \sin (\gamma )-\sin (\alpha ) \cos (\gamma ) \\ -\sin (\beta ) & \sin (\alpha ) \cos (\beta ) & \cos (\alpha ) \cos (\beta )\end{array}\right) \left(\begin{array}{c} x_B-x_A \\ y_B-y_A \\ z_B-z_A\end{array}\right)$