# Math Help - Get the end position of a spherical segment line.

1. ## Get the end position of a spherical segment line.

I just want to say: This is my first time here and I haven't taken trig just yet, so bar with me a bit.

Hey guys, I been trying at this problem for a few days now, but to no luck. I am taking a spherical object that is using a heading, pitch, roll type movement and trying to cast a line segment from it and then get the end point of that line segement. Can anyone show me the math behinde it?

I know it's wrong, but here's what I did try:
Code:
from math import cos, sqrt, tan, sin, radians, degrees
x1 = 0
y1 = 0
z1 = 0
P = 90
H = 0
R = 0
D = 10
x2 = round(degrees(sin(radians(H)) * cos(radians(P)))) * D + x1
y2 = round(degrees(sin(radians(H)) * sin(radians(P)))) * D + y1
z2 = round(degrees(cos(radians(H)))) * D + z1
print x2, y2, z2
I was using the math I saw here: Spherical coordinate system - Wikipedia, the free encyclopedia Someone pointed me to this link to help solve the issue from ##Math.

Hope it's ok that is it is in programing code. Should still be readable in anycase. (D)istance I want to move in from the position of where the spherical object is looking at using (P)itch and (H)eading. As for roll we can leave at as 0.