Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Jyujinkai on January 04, 2009, 04:08:58 AM

Title: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
Post by: Jyujinkai on January 04, 2009, 04:08:58 AM
Code: WME Script
  1. Math.Sin();
  2. Math.Cos();

In the manul it says....

Code: WME Script
  1. Cos(Angle)
  2. Returns the cosine of a number
  3.  
  4. Parameters
  5. Angle
  6. Angle in degrees
  7.  
  8. Sin(Angle)
  9. Returns the sine of a number
  10.  
  11. Parameters
  12. Angle
  13. Angle in degrees

I was woundering is the input value here a RADIAN or a ANGLE. It says it returns an angle in degrees, but I am not sure what format gose into it....

I "think" it is radians.. is this correct?
Title: Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
Post by: Mnemonic on January 04, 2009, 09:33:45 AM
Errr, no...
An angle is an angle, it's measured either in degrees or in radians.
Title: Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
Post by: Jyujinkai on January 04, 2009, 10:12:52 AM
Errr, no...
An angle is an angle, it's measured either in degrees or in radians.
ummm yea.... but If i have an angle that is 20 degrees... and I do

Code: WME Script
  1. // Use the Degrees in there?
  2. var Question1 = Math.Cos(20); // Out Put is in Degrees? or Output in Radians?
  3. // Use the radians in there?
  4. var Question2 = Math.DegToRad(20);
  5. Question3 = Math.Cos(Question2); // Out Put is in Degrees? or Output in Radians?
  6.  

Am i makign sense? What i am asking is when shoudl I be converting angl;es into radians.... At the start convert degrees into radians and then just use them from then on?
Title: Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
Post by: Mnemonic on January 04, 2009, 10:26:28 AM
The docs say the Math.Cos() expects an angle in degrees. So, if you have a value in degrees, you can pass it directly. If you have a value in radians, you need to convert it to degrees first and then pass it to Cos().
Title: Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
Post by: Jyujinkai on January 04, 2009, 05:12:37 PM
Oh ok... so the only time you need to convert into radians and back is when using
Code: WME Script
  1. Math.Atan2(Y,X);
  2.  
  3. /*Atan2(Y, X)
  4. Returns the angle (in radians) from the X axis to a point (y,x)
  5.  
  6. Parameters
  7. X
  8. A number representing the cartesian x-coordinate
  9. Y
  10. A number representing the cartesian y-coordinate */

apart from that all Math.Methods take Degrees and return Degrees?

<------- Edit (Side Question)
Atan2 works on cords... so if you have 2 points Xa,Ya and Xb,Yb then .Atan2(Xa,Yb); ??