Find the point on a circle with given center point, radius, and degree

后端 未结 10 1866
后悔当初
后悔当初 2020-12-02 06:57

It\'s been 10 years since I did any math like this... I am programming a game in 2D and moving a player around. As I move the player around I am trying to calculate the poin

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 07:46

    I also needed this to form the movement of the hands of a clock in code. I tried several formulas but they didn't work, so this is what I came up with:

    • motion - clockwise
    • points - every 6 degrees (because 360 degrees divided by 60 minuites is 6 degrees)
    • hand length - 65 pixels
    • center - x=75,y=75

    So the formula would be

    x=Cx+(r*cos(d/(180/PI))
    y=Cy+(r*sin(d/(180/PI))
    

    where x and y are the points on the circumference of a circle, Cx and Cy are the x,y coordinates of the center, r is the radius, and d is the amount of degrees.

提交回复
热议问题