• Advertisement

Archived

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

cos problem realy easy

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

Advertisement
radian = degree * pi / 180
degree = radian * 180 / pi

edit: all c function use radian.

[edited by - Wildfire on January 31, 2003 4:40:49 AM]

Share this post


Link to post
Share on other sites
doesn't seem to work i'm using the cosine rule to to find a value then doing acos of that but it doen't work am i doing it right or horribly horribly wrong.

[edited by - hello_there on January 31, 2003 4:47:54 AM]

Share this post


Link to post
Share on other sites

    
float angle1 = 45; //degrees

float sine //sinus;

float radians //radians;

float angle2 //degrees;


sine = sin(angle1 * 3.141/180); //convert to radians, c wants radians, not degrees


radians = asin(sine); //c will return the angle in radians


angle2 = radians * 180 / 3.141; //reconvert to degrees



[edited by - Wildfire on January 31, 2003 4:54:56 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by hello_there
what''s the function for inverse cosine?

You know, it would be helpful if you specified a language.

Share this post


Link to post
Share on other sites
so i use the cosine rule to find out a number which is number = ((b*b)*(c*c)-(a*a))/(2*b*c). then what?



[edited by - hello_there on January 31, 2003 5:24:58 AM]

Share this post


Link to post
Share on other sites
you know what the cosine does/is, not? if you don''t, RTFschoolpapers on trigonometry you have or not. if you don''t, you have to ask your math teacher, or STFW, or what ever.

get infos yourself, your question is answered..

that sounded harsh now, didn''t it?:D

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
Maybe you should state what exactly you are trying to do in the first place?

Your original question was about the inverse function of sin/cos. The question has been answered far more in detail then anyone should have. Because, searching for ''sin'' or ''cos'' on MSDN (for example) will already wield a link to ''asin'' and ''acos''.

The basic idea is that ''sin/cos'' calculate the sinus or cosinus of an angle/radians. ''asin/acos'' reverses that.

Share this post


Link to post
Share on other sites
i did it last year and know how to do it but c++ does it differently cause my calculator doesn't do it in radians. all i need to do on my calculator is do the cosine rule then press inverse cosine button then there's the answer.

[edited by - hello_there on January 31, 2003 5:29:12 AM]

Share this post


Link to post
Share on other sites
what i'm trying to do is find the 3 angles that are around the player from the line that conect to each point on the triangle which should be close to 360 degress if the point in colliding with the triangle and some other number not close to 360 if it's not. that doesn't make much sence it would be easier to explain in a picture. but hopfully someone understands. also doesn't cos find a length and inverse cos find a angle?

[edited by - hello_there on January 31, 2003 5:37:37 AM]

Share this post


Link to post
Share on other sites
edit: changed as you've given more info

Cosine of an angle gives you a ratio of two sides of a right angled triangle. That ratio is the same no matter how big you scale the triangle to be. It's a unitless ratio.

Inverse cosine takes that ratio of two lengths. It assumes those lengths are two sides of a right angled triangle, one being the hypotenuse and the other being the side adjcent to the angle you're interested in. It tells you the angle.

Write shorter sentences. Spend time editing before you post. I really can't believe you come from an english speaking country or are over the age of 12.

[edited by - petewood on January 31, 2003 5:53:25 AM]

Share this post


Link to post
Share on other sites
What you are looking for is the dot product. This will give you the angle between two vectors.

You''ll have to define three vectors, going from your player to each edge of the triangle. Then calculate the angles between all three and sum them up.
This approach does not work very well, because floating numbers tend to have accuracy problems, and might tell you the angle is <360° even though it should be.

Share this post


Link to post
Share on other sites

  • Advertisement