Jump to content
  • Advertisement

Archived

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

Tire

Real easy math question...

This topic is 6978 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 remember my math lessons right there is something called 'cosinus regel' (maybe translated to cosine rule?), but unfortunately I've forgotten this (doh!).

Share this post


Link to post
Share on other sites
Advertisement
It's either that or the law or sines...Here is the formula for the law of cosines to get angle a from entering all 3 sides:

A = side a
B = side b
C = side c

B² + C² - 2BC/A²

Hopefully that helped. You could just figure out the 3rd side or make one up until you get what you're wanting.

Share this post


Link to post
Share on other sites
Actually, in triangle trigonometry you need to know THREE things; either three sides, two sides and the INCLUDED angle, or one side and the two adjacent angles. Just two sides will not give you anything.

Also, pretty sure the cosine rule is for SAS, not SSS, and it reads:

a^2 = b^2 + c^2 - 2bc cos A

That gets you the third side given two sides and the included angle.

- Splat

Share this post


Link to post
Share on other sites
Linear algebra to the rescue!!

Let vA be one of your sides (tail at the origin) and vB be the other side (tail at the origin).

Then you can use this formula to find the angle between any two vectors (works in n-dimensions too :-)

angle = acos (vA . vB / (|vA| * |vB|))

Note that "vA . vB" is the inner (dot) product of vA and vB, and |vA| represents the magnitude of the vector vA.

I believe this formula is derived from the cosine rule which Splat stated.

Share this post


Link to post
Share on other sites
Thanks for refreshing my memory. I think I got it. If c and b are my known sides and A is the desired angle between c and b (SAS) then I can figure out side a with the distance formula because I know the points that make up lines b and c. Now I can use the law pf cosines and solve for cos A:

cos A = (b^2 + c^2 - a^2) / 2bc

Then I can use the arc-cosine function to find the angle A:

acos(cos A) or
acos((b^2 + c^2 - a^2) / 2bc)

I think that will work.

Share this post


Link to post
Share on other sites
I don't think you have got it. I mean, you don't have the a, so you can't use the cosine rule.

I think I will use my brains for a while to point out that it is hardly possible (with my undrstanding)

Since a traingle can be everything, you can use Pythagoras to solve this. So you need something else.

You only know two sides, and would like to knw the angle between them. This is NOT possible. If you just think about it. If the length of one side is 2 and the other is 3. Then the angle could be anything...let's just say 45. But the same angle could be with lengths of 1000 and 345. Tha \t doesn't matter.

You can only solve this equation if you know, for, instance the length of 3 sides.
This could be accomplished if you know both the starting position and end position of each line of the triangle. This would also make it much easier. You probably have those coordinates, because you write them (probably) to the screen, and you could just use those.

Now I am thinking about it. If you are absolutely sure that the angle is less than 90 degrees, then you might want to try to make a line right up to the other one, and see where that line will collide with again the second line
(ie. line a, b and c....line c, right at a, and see where c hits b)
Then you could use Pythagoras.

Enough brainstorming, wasn't f any help I think

------------------
Dance with me......

Share this post


Link to post
Share on other sites
Basically, as I said above, you need to know THREE OR MORE things about a triangle to figure out the rest. With two sides you have an infinite number of possibilities. SAS, ASA, SSS, SAA contain enough knowledge to get you the rest of the triangle, but AAA and ASS don't.

- Splat

Share this post


Link to post
Share on other sites
Yes, in pure mathematics, this problem can not be solved (we do need to know three things), but since this most certanly will be plotted to the screen or something, we would know the coordinates! (strange thing would be if we din't!) So set up things like this:

We have two lines a and b. line a has the end coordinates (ax,ay) and the shared coordinate (abx,aby). Line b is (bx,by) to the shared (abx,aby). From the two "loose" endpoints we create a third line, c. The coordinates in wich this line exists is (ax,ay) and (bx,by).

The length of a and b is given. Length of c is sqr((ax-bx)^2+(ay-by)^2).

Geometric laws (Cosine rule): c^2 = a^2 + b^2 - 2abCos(C) // (C is the wanted angle)

wich means that Cos(C) = (c^2-a^2+b^2)/(-2ab)

I think that this would be the best way to deal with the situation.

Share this post


Link to post
Share on other sites
I want to find the angle between two sides of a triangle. Is it possible to find one of the angles of a non-right triangle if all I know are the lengths of 2 sides? If so, how?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!