Jump to content
  • Advertisement
Sign in to follow this  
sporedude

Help with Triangle

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

hi all I wanted help with the following. I have a triangle in 3D with coordinates of 2 of its vertices given. I am also given the length of the 3 sides of the triangle. Now I need to find the coordinates of the 3rd vertex. Now this might just be elementary geometry but i would appreciate if someone could help me with it. SD

Share this post


Link to post
Share on other sites
Advertisement
In 3D? There are an infinite number of triangles that can be created with only that information.

Share this post


Link to post
Share on other sites
hey Joe,

I thought there can be only 2 possible triangles that can be created in 3D with 2 vertices fixed and the lengths of the 3 edges given.

cheers

Share this post


Link to post
Share on other sites
oh yeah.... i got that.... there can be infinite no. of triangles with the 3rd vertex leading to formation of a circle.

what if i assume that all the 3 vertices of the triangle are in the same plane. then i guess there would be 2 possible traingles. how would i find the 3rd vertex then?

cheers

Share this post


Link to post
Share on other sites
Quote:
Original post by sporedude
oh yeah.... i got that.... there can be infinite no. of triangles with the 3rd vertex leading to formation of a circle.

what if i assume that all the 3 vertices of the triangle are in the same plane. then i guess there would be 2 possible traingles. how would i find the 3rd vertex then?

cheers


All three vertices have to be on the same plane if they form a triangle. Think of the two vertices as forming a hinge. For example, hold a pen between your thumb and index finger. Imagine a triangular paper flag extending from the pen. Hold your hand in the same place and swivel the paper triangle flag around the pen.

You can find the range of all possible triangles, but there are an infinite number of them.

What you may want to do is convert this problem into 2D and understand how it works. In 2D there are only two solutions.

Share this post


Link to post
Share on other sites
Here is an example of finding one of the possible vertices of a 2D triangle, given vertex(3,3), vertex(7,7), and lengths:
(between (3,3) and (?,?): length 4
(between (7,7) and (?,?): length 4
(between (3,3) and (7,7): length 5.657 (actually we could calculate this ourselves too).




Basically, what we did was use the cosine rule to calculate the angles between the vectors. Then we used these angles to calculate a unit vector representing the third unknown vector. We then scaled this unit vector by the length of the known side and then translated it into the correct position to get the exact coordinates.

Let me know if you have any questions. There are also optimized ways of doing this.

[Edited by - jdaniel on May 16, 2006 10:24:54 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by jdaniel
All three vertices have to be on the same plane if they form a triangle.


In fact, 3 points always belong to a same plane, which is unique if the 3 points are different, or which can be an infinite number of plane if at least 2 points are identical.

To me your sentence sound as if one could find 3 points for which there would be no plane that would contain all three of them. It would be as if in 2D geometry there could be "two non-aligned points"

Just wanted to clear that up for non-geometry-friendly folks out there.

Quote:
In 3D? There are an infinite number of triangles that can be created with only that information.


In fact, there could be an infinity of solutions (without going into the math details, that would be true if the two other edge length would be "large enough") or exacly one solution (if the two edges are "just the right length") or no solution at all (if the two edges are "too short")

But this is easier to understand when thinking of a 2D space (for which this problem's solution could be either: two triangles, one triangle or no triangle at all)

--------------------------

Say (x,y) is what you're looking for.

(1) - Then ,distance-to-the-point(3,3)=4 condition:

(x-3)*(x-3) + (y-3)*(y-3) = 4 * 4
<=> x^2 - 6x + 9 + y^2 - 6y + 9 = 16

(2) - Also ,distance-to-the-point(7,7)=4 condition:
(x-7)*(x-7) + (y-7)*(y-7) = 4 * 4
<=> x^2 - 14x + 49 + y^2 - 14y + 49 = 16

Frow what you can get (1) - (2):
8x - 40 + 8y - 40 = 0 <=> x + y = 10 <=> y = 10 - x

Feed that into (1) and you'll get that:
x^2 - 6x + 9 + (10 - x)^2 - 6(10-x) + 9 = 16

Which you can easily simplify to a simple 2nd degree polynom, which you can solve with REAL values (finding complex solution would have no point, well, I think, for a trival application at least)

- If there are two solutions, then it means the circles intersect at two different locations, which means there are two trianglees that fit.

- If there is only one solution, it means that the circles are tangential and intersect only at a single location

- If there are no solution at all, it means that the circles do not intersect with each other.

(So, that demonstrates what I said before: 2, 1 or 0 solution)

The same method could be extended to a 3D world, in which the known distances from each known vertex would describe two spheres, and their intersection would be a circle, a point or nothing at all.

I hope I could give you another perpective for solving this problem.
Sorry that my native language is not english so my mathematical vocabulary might not be perfect, while understandable (I hope :p)

Janta

Share this post


Link to post
Share on other sites
Quote:
Original post by sporedude

what if i assume that all the 3 vertices of the triangle are in the same plane.


What if you don't ? :D ;-)

Well, if you don't, then you just reinvented the euclidian geometry (or some stuff like that since I'm no math expert though :p)

What I just mean is that 3 vertices in a 3D space have no choice but to be in the same triangle/plane.

Share this post


Link to post
Share on other sites
thanks janta and jdaniel. you insights were really helpful.

daniel thanks for pointing out the Cosine rule mate... that could actually do the trick for me. i will keep posted if i have trouble implementing it.

janta ... thanks for your rather deep insight. I haven't read your post closely but from what i can make out, u seem to be a perfect 'geometrician'.

Thanks for poiting the basic flaw in my assumption. I agree that 3 points in 3D space have to be only a plane... they have no choice. guess i was confused with the possibility of there being inifite no. of solutions. thanks for pointing it out.

cheers

Share this post


Link to post
Share on other sites
janta i liked u method of finding the polynomial and then solving it too, as it tend to cover all the conditions (2, 1, and 0). I would try implementing that too.. thanks a lot

cheers

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.

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!