pythonparametric-equations

Problem with parametric equation in Python


I am trying to determine a point x,y on a circle with a radius r for which I want to apply a paramteric equation as described on: https://www.mathopenref.com/coordparamcircle.html

import math

radius = 45
t = 10

x = radius*math.cos(t)
y = radius*math.sin(t)

For x and y I get the following output:

x
Out[217]: 5.253219888177298

y
Out[218]: 8.509035245341185

I don't understand why. As far as I understand, x and y should have the same value if r is 45. Any idea?


Solution

  • Note that t is 10 here.

    When the input for t is 45 degrees then they should give you the same value. You have to convert them to radian though.

    import math
    
    radius = 10
    t = 45
    
    x = radius*math.cos(math.radians(t))
    y = radius*math.sin(math.radians(t))
    print(x,y)
    

    gives us

    7.07106781187 7.07106781187