Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)  (Read 4748 times)

0 Members and 1 Guest are viewing this topic.

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
« 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?
« Last Edit: January 04, 2009, 04:31:45 AM by Jyujinkai »
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
« Reply #1 on: January 04, 2009, 09:33:45 AM »

Errr, no...
An angle is an angle, it's measured either in degrees or in radians.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
« Reply #2 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?
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
« Reply #3 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().
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: Confused about ANGELS and RADIANS (Math.Cos / Math.Sin)
« Reply #4 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); ??
« Last Edit: January 04, 2009, 05:22:04 PM by Jyujinkai »
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe
 

Page created in 0.044 seconds with 20 queries.