Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Maths: getting degrees from radians (or am I wrong?)

    6 answers - 665 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hello,
    I have this little math problem. I have this formula from wich I get a
    dot product between two vectors.
    cos() = A.B / |A|.|B| = -0.0634
    So this would give me radians, right?
    Then if I use
    math.degrees( -0.0634 )
    This gives me a value of -3.6325524211294193.
    However I have a book in front of me who says I should get a value of
    93.635 degrees. mmmmm
    Btw, in the book, the equation is written
    = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
    I'm just interpreting this wrong?
    Thanks
    Bernard
    Tutor maillist - Tutor (AT) python (DOT) org
  • No.1 | | 1154 bytes | |

    Bernard Lebel wrote:
    Hello,

    I have this little math problem. I have this formula from wich I get a
    dot product between two vectors.

    cos() = A.B / |A|.|B| = -0.0634
    So this would give me radians, right?

    No, it's the cosine of , which has no units (a cosine is a ratio of two lengths)

    Then if I use

    math.degrees( -0.0634 )

    This gives me a value of -3.6325524211294193.

    However I have a book in front of me who says I should get a value of
    93.635 degrees. mmmmm

    Btw, in the book, the equation is written

    = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
    I'm just interpreting this wrong?

    The -1 means inverse. You have cos() = -0.0634 - you want to find the angle whose cosine is -0.0634, i.e. (inverse cosine)(-0.0634). Another name for cos-1 is arccosine. In Python it is math.acos():
    import math
    math.acos(-0.0634)
    1.6342388771557625
    math.degrees(_)
    93.634990377223801

    Kent

    Thanks
    Bernard

    Tutor maillist - Tutor (AT) python (DOT) org

    Tutor maillist - Tutor (AT) python (DOT) org
  • No.2 | | 326 bytes | |

    Bernard Lebel wrote:

    import math
    math.acos(-0.0634)
    1.6342388771557625
    math.degrees(_) < in all my time on tutor
    I have never noticed
    this underscore trick
    before
    93.634990377223801

    That's quite handy.

    Alan

    Tutor maillist - Tutor (AT) python (DOT) org
  • No.3 | | 351 bytes | |

    21/09/05, R. Alan Monroe <amonroe (AT) columbus (DOT) rr.comwrote:
    math.degrees(_) < in all my time on tutor
    I have never noticed
    this underscore trick
    before

    I'm not a big fan of it, actually. It smells of Perl and those opaque
    one-liners that make use of implicit functions implicitely setting
    implicit variables
  • No.4 | | 592 bytes | |

    John Fouhy wrote:
    21/09/05, R. Alan Monroe <amonroe (AT) columbus (DOT) rr.comwrote:

    math.degrees(_) < in all my time on tutor
    >>

    >I have never noticed
    >this underscore trick
    >before


    I'm not a big fan of it, actually. It smells of Perl and those opaque
    one-liners that make use of implicit functions implicitely setting
    implicit variables

    It also only works in *interactive* interpreters. -- Poor Yorick

    Tutor maillist - Tutor (AT) python (DOT) org
  • No.5 | | 799 bytes | |

    John Fouhy wrote:
    21/09/05, R. Alan Monroe <amonroe (AT) columbus (DOT) rr.comwrote:

    math.degrees(_) < in all my time on tutor
    >>

    >I have never noticed
    >this underscore trick
    >before


    I'm not a big fan of it, actually. It smells of Perl and those opaque
    one-liners that make use of implicit functions implicitely setting
    implicit variables

    I'm actually not much of a fan either - it's too easy to lose what I wanted by doing another step, then it's too late. And I usually don't use it on tutor because I think it is a bit obscure. This time I wondered if anyone would notice :-)

    Kent

    Tutor maillist - Tutor (AT) python (DOT) org
  • No.6 | | 1413 bytes | |

    thanks a lot everyone.

    Bernard

    9/20/05, Kent Johnson <kent37 (AT) tds (DOT) netwrote:
    Bernard Lebel wrote:
    Hello,

    I have this little math problem. I have this formula from wich I get a
    dot product between two vectors.

    cos() = A.B / |A|.|B| = -0.0634
    So this would give me radians, right?

    No, it's the cosine of , which has no units (a cosine is a ratio of two lengths)
    --
    Then if I use

    math.degrees( -0.0634 )

    This gives me a value of -3.6325524211294193.

    However I have a book in front of me who says I should get a value of
    93.635 degrees. mmmmm

    Btw, in the book, the equation is written

    = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
    I'm just interpreting this wrong?

    The -1 means inverse. You have cos() = -0.0634 - you want to find the angle whose cosine is -0.0634, i.e. (inverse cosine)(-0.0634). Another name for cos-1 is arccosine. In Python it is math.acos():
    import math
    math.acos(-0.0634)
    1.6342388771557625
    math.degrees(_)
    93.634990377223801

    Kent
    >
    >
    >

    Thanks
    Bernard

    Tutor maillist - Tutor (AT) python (DOT) org

    >
    >
    >


    Tutor maillist - Tutor (AT) python (DOT) org

    Tutor maillist - Tutor (AT) python (DOT) org

Re: Maths: getting degrees from radians (or am I wrong?)


max 4000 letters.
Your nickname that display:
In order to stop the spam: 4 + 4 =
QUESTION ON "Python"

EMSDN.COM