Jump to content
  • Advertisement

Archived

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

NeoPnoy

Really dumb math problem.

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

Ok this is probably easy for you guys but i dont know how to do this. I have 2 lines. I vertical and the other one is dynamic which means it can be pointing at any direction. (x1,y1) C /\ / \ b/ \a / \ / \ (x2,y2) (x3,y3) how do i find the angle betweent them? that angle im trying to find is angle C. how do i do that? btw. both lines start out in the same direction, and if i connect the enpoints, it will make a right triangle. email me at neopnoy@yahoo.com thanks.

Share this post


Link to post
Share on other sites
Advertisement
Ok, well, since they both begin at the same point and form a right angled triangle, you can use the cosine ratio to find the angle.

simply call your languag''s inverse cosine function on the two lines'' lengths.

-Mezz

Share this post


Link to post
Share on other sites
I forgot the law of cosines. What is it again? And how do you the inverse or sine or cosine on the comp? What functions?

Share this post


Link to post
Share on other sites
hi
you can use dot product in order to find cosine :
let be AB the vector for the first line defined by points A(xa,ya) and B(xb,yb) and CD the vector for the second line defined by points C(xc,yc) and D(xd,yd)
so we have :

AB(xb-xa,yb-ya) CD(xd-xc,yd-yc)

AB.CD=/AB/*/CD/*cos(AB,CD)

with /AB/=sqrt((xb-xa)²+(yb-ya)²)
/CD/=sqrt((xd-xc)²+(yd-yc)²)

we have also:
AB.CD==((xb-xa)*(xd-xc))+((yb-ya)*(yd-yc))

so :
cos(AB,CD)=(((xb-xa)*(xd-xc))+((yb-ya)*(yd-yc)))/(sqrt((xb-xa)²+(yb-ya)²)*((xd-xc)²+(yd-yc)²))


in order to find sine, use cross product

AB X CD=/AB/*/CD/*sin(AB,CD)

we have also

AB X CD=a*d-b*c

so :

sin(AC,CD)=(a*d-b*c)/(sqrt((xb-xa)²+(yb-ya)²)*((xd-xc)²+(yd-yc)²))

you have to calculate both sine and cosine because for one value of cosine you have two angles : cos (alpha) = cos (-alpha)

>>And how do you the inverse or sine or cosine on the comp? What functions?
sorry i don''t know!

hope that help

lunasol

Share this post


Link to post
Share on other sites
By inverse of cosine or sine do you mean finding the angle when you know the value? If so, use acos(), asin(), and atan(). These are arc cosine, arc sine, and arc tangent.

Morgan

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.

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!