Archived

This topic is now archived and is closed to further replies.

phaelax

3d line segment

Recommended Posts

phaelax    126
If I know 1 point(point A) and two angle''s of rotation(x and y), and the distance from from point A in 3D space, how could I find the coordinates for point B?

Share this post


Link to post
Share on other sites
Atheist    150
Depends on what your angles x and y refer to. But in general try constructing a direction u (unit vector) from your angles. Then:
b = a + d*u
where d is the distance while a and b are the coordinates of point A and B respectively.

Share this post


Link to post
Share on other sites
oliii    2196
that would be something like that

Dir.x = cos(rotation) * cos(elevation);
Dir.y = sin(elevation);
Dir.z = sin(rotation) * cos(elevation);

B.x = A.x + Dir.x * distance;
B.y = A.y + Dir.y * distance;
B.z = A.z + Dir.z * distance;

Share this post


Link to post
Share on other sites
phaelax    126
thx guys. I came up with this just before I checked back here.

height = sin(elevation) * distance
gdistance = cos(elavation) * distance

b.x = a.x + cos(Yrotation) * gdistance
b.y = a.y + height
b.z = a.z + sin(Yrotation) * gdistance

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by oliii
that would be something like that

Dir.x = cos(rotation) * cos(elevation);
Dir.y = sin(elevation);
Dir.z = sin(rotation) * cos(elevation);

B.x = A.x + Dir.x * distance;
B.y = A.y + Dir.y * distance;
B.z = A.z + Dir.z * distance;


Oliii, why are you so damn good at maths, physics etc? How long have you been studying these things for, and have you got any other education on this stuff or did you teach yourself everything? ie: what''s your math background? You never stop amazing me...

Share this post


Link to post
Share on other sites
oliii    2196
To be fair, it''s not that advanced. For example, if you pickup the OpenGL red book, it''s in there. I did a Master in Computer Graphics & Virtual Reality, and yeah, I learned a few tricks there, but it''s trigonometry, coordinate systems (it''s like latitude / longitude earth coordinates). You can pretty much self teach these things with books, the net, and coding, once you know basic vector maths, trig, algebra, good A-level maths, really. All the rest come with experience. And I do work in the game industry, so it''s my job to know

A lot of people around here know that stuff, I''m just a bit quicker at replying. But thanks anyway.

Share this post


Link to post
Share on other sites
phaelax    126
There''s a book with those equations in it? I just looked at it in terms of 2 dimensions at first, cause that''s easier. I came up with that by using pythagorean theorem.

Share this post


Link to post
Share on other sites
oliii    2196
that''s a very good effort indeed

It''s a lot easier to visualise if you draw it on paper, then you can see the angles and their relationship, the way they describe a sphere. It''s a polar coordinate system, where coordinates are not expressed as (x, y, z), but with (theta, phi, rho), where ''theta'' is your ''rotation'' angle (longitude), ''phi'' is your ''elevation'' angle (or latitude), and ''rho'' is the distance from origin (can be compared with an ''altitude'', a distance from earth''s centre). (all greek lettersare just for conventions ).

Then the operation I describe and that you came up with, is a conversion from polar coordinates to cartesian orthogonal coordinates ((x, y, z) triple to you and me).

then you have the inverse operation. From cartesian to polar. Have fun working that one out

Share this post


Link to post
Share on other sites