A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Cos-1 ??

  1. #1
    Member
    Join Date
    Feb 2005
    Location
    The Netherlands
    Posts
    41

    Cos-1 ??

    How do I do cos-1?


    I tried to do Math.acos, but it gave me NaN

    im using flash 6 btw
    Last edited by Define_Robert; 01-27-2006 at 11:38 AM.

  2. #2
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Math.acos should work

    what numbers did you use?
    are you using radians?

  3. #3
    Member
    Join Date
    Feb 2005
    Location
    The Netherlands
    Posts
    41
    Quote Originally Posted by ozmic66
    Math.acos should work

    what numbers did you use?
    are you using radians?
    What are radians?


    I just learned sin cos tan at school, so I wanted to try it with flash

  4. #4
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472

    radians

    Hey,

    I'm sure that there's a million explenations on the web for that, but i'll give it a try too

    radians are just like degrees in that they are a measure of an angle

    degrees are different from radians in that they range from 0 to 360, and radians from 0 to 2*PI
    (or 6.28..., but it is conventional to write the measure for radians with the PI symbol instead of multiplying out)
    but other than their range, deg's and rad's are completely the same!

    saying that an angle is 180 degrees, is like saying that it is PI (3.14..) radians


    there's actually a reason that people use radians (other than to be annoying) but i can't really remember it right now - try looking it up

    so when i said that flash uses radians (like most c based languages out there) i meant that you need to convert whatever degrees you are using to radians

    to do that, you multiply the degree amount by PI/180 (or 0.01745329.... but you can see which one is easier to use)
    to convert from radians back to degrees, multiply by 180/PI

    you can use the flash constant Math.PI for a pretty percise number

    also, going back to your original question, remember that:

    when using arcCos (cos-1) you input a number value (like adjacent/hypotonous) and get back a radian value (which you can convert to degrees with the above method)

    if you want to figure out the cos() of a cetain angle, you input the angle in radians, and get back a ratio (opp/hyp)

    i hope that helps

    if you have any questions, do ask
    Last edited by ozmic66; 01-28-2006 at 05:05 PM.

  5. #5
    Member
    Join Date
    Feb 2005
    Location
    The Netherlands
    Posts
    41
    Hmm, I'm confused...

    I did not understand it entirely, mainly because it's in english

    In my homework everything about sin cos tan is good(it's basic), but in Flash I just can't do it

    But why are you using PI ?

    Last edited by Define_Robert; 01-28-2006 at 06:41 PM.

  6. #6
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    what exactly do you mean 'i can't do it in flash'?

  7. #7
    Member
    Join Date
    Feb 2005
    Location
    The Netherlands
    Posts
    41
    I made a picture(its a sketch)

    http://img383.imageshack.us/img383/6787/cos8sy.jpg

    Normal I would use cos-1 on my calculator, but here if I use Math.acos I get 0.722734247813416, but on my calculator I get 41.40962211

  8. #8
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    here's the problem:

    flash uses radians, meaning its giving you the angle amount in a number between 0 - 2*PI, so...

    to convert from radians to degrees, you need to multiply by 180/PI

    so 0.722734247813416 radians * 180/PI should equal 41.40962211 degrees
    Last edited by ozmic66; 01-28-2006 at 09:10 PM.

  9. #9
    Member
    Join Date
    Feb 2005
    Location
    The Netherlands
    Posts
    41
    OK thx a lot!!!!

  10. #10
    there's actually a reason that people use radians (other than to be annoying) but i can't really remember it right now - try looking it up
    The reason why radians is so important is that thye are real numbers. A radian has a unit of... well... number. A degree has a unit of .... degrees. 2 * 360 degrees... doesn't make sense. 2 * 2(PI) radians does however.

    1 degree = PI/180

    And yes, cos-1 = Math.acos

  11. #11
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    Quote Originally Posted by Mattachoo
    2 * 360 degrees... doesn't make sense. 2 * 2(PI) radians does however.
    ...i'm not sure i understand why


    radians are actually used because they provide a way to measure the actual length of the arch that a certain angle makes with a particular radius
    wikipedia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center