Jump to content
  • Advertisement
Sign in to follow this  
Bong Chua

xyz

This topic is 4241 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to get the End Point (x,y,z) of a certain line with fixed Radius and at fixed vertex at (0,0,0). I have an instrument to give me angle (theta) when the line moves either up or down. I also placed an angular meter to give me angle when the line moves either clockwise or counterclockwise. I would appreciate any advice on how to calculate the end points. Thank you very much.

Share this post


Link to post
Share on other sites
Advertisement
end_point(x,y,z) = origin(x,y,z) + line_direction(x,y,z) * line_length(radius)

eg, origin = (0,0,0), direction = (0.5,0.5,0), length = 100

End(x) = 0 + 0.5 * 100
End(y) = 0 + 0.5 * 100
End(z) = 0 + 0 * 100
End = (50,50,0)


Is that what you were asking for?

Share this post


Link to post
Share on other sites
Thank you for your reply.
I want to attach a sketch but I dont know how.

Anyway, please imagine am holding a straight stick pointing to the sun. The lenght of stick is known as Radius (R).
1. With a given instrument I will be able to know the angle of the stick with reference to the ground (theta).
2. With another given instrument, I will be able to know the angle when the stick either moves to the left or right direction (phi).

Now, i want to calculate the (x,y,z) point at the end of the stick. How can i do that? Thank you very much for your kind help.

Share this post


Link to post
Share on other sites
You need trigonometry.

Its slightly easier if we do it for Radius=1, then multiply by the real radius at the end.

First, lets look at the horizontal angle, Theta - this will give us x and z

Sin(angle) = Opposite/Hypotenuse
Cos(angle) = Adjancent/Hypotenuse
Tan(angle) = Opposite/Adjacent


h=1, o=z, a=x

z = Sin(theta)
x = Cos(theta)

Now we have the line in two dimensions, but we need the vertical component from Phi.

h=Radius, Opp=y, Adj=Horizontal_To_Vertical_Ratio

y = Sin(phi)
ratio = Cos(phi)

Now we need to combine the first 2D line with the vertical component using the "Horizontal_To_Vertical_Ratio". Then we can multiply by the radius

y = y*(1-ratio) *Radius
z = z*ratio *Radius
x = x*ratio *Radius


Here's an explanation of trigonometry:
http://www.mathwords.com/s/sohcahtoa.htm

[Edited by - PhilMorton on October 16, 2006 1:19:45 AM]

Share this post


Link to post
Share on other sites
The OP actually means a conversion from spherical to cartesian co-ordinates.
Look e.g. here:
http://mathworld.wolfram.com/SphericalCoordinates.html
http://en.wikipedia.org/wiki/Spherical_coordinates

Share this post


Link to post
Share on other sites
Quote:
Original post by haegarr
This is actually a conversion from spherical to cartesian co-ordinates.
Look e.g. here:
http://mathworld.wolfram.com/SphericalCoordinates.html
http://en.wikipedia.org/wiki/Spherical_coordinates


I guess my explanation is just a manually derived version of this wikipedia image...



Go Wikipedia!

Share this post


Link to post
Share on other sites
Quote:
Original post by PhilMorton
Quote:
Original post by haegarr
This is actually a conversion from spherical to cartesian co-ordinates.
Look e.g. here:
http://mathworld.wolfram.com/SphericalCoordinates.html
http://en.wikipedia.org/wiki/Spherical_coordinates


I guess my explanation is just a manually derived version of this wikipedia image...

Sorry, the formulation I've chosen wasn't clear: With "This is actually ..." I meant the OP's problem but wasn't concerning your above answer .

You are right in using trigonometrics for this problem. However, I suspect the conclusions in your 2nd reply, since after cancelling there remains
1 - ratio = ratio
Perhaps it would be nice for the OP if you give him some explanations for what you mean there.

Share this post


Link to post
Share on other sites
Hi Haegarr and Phil,

Thanks a lot. I think that is what I am looking for. Spherical Coordinates. I am now making my algorithm for my application and so far i am getting the correct results.

Thank you very much.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!