Calculating point on a circle's circumference from angle in C#?

后端 未结 6 996
故里飘歌
故里飘歌 2020-11-29 03:43

I imagine that this is a simple question, but I\'m getting some strange results with my current code and I don\'t have the math background to fully understand why. My goal

6条回答
  •  忘掉有多难
    2020-11-29 03:54

    I don't know c#, anyway if you are trying to draw the points somewhere you have to consider the fact that the Y axis crease from the top to the bottom of the screen, so your sin element should have be -sin(...) and not +sin(...)

    so

    result.Y = centerPoint.Y + (int)Math.Round( distance * Math.Sin( angle ) );
    

    should become:

    result.Y = centerPoint.Y - (int)Math.Round( distance * Math.Sin( angle ) );
    

    If you are not trying to draw them I could not imagine what the problem is, can you give some example?

提交回复
热议问题