Jump to content
• Advertisement

#### Archived

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

# 3d line segment

This topic is 5414 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

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

##### Share on other sites
Advertisement
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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
69
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011827
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!