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

后端 未结 6 989
故里飘歌
故里飘歌 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 04:11

    You forgot to add the center point:

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

    The rest should be ok... (what strange results were you getting? Can you give an exact input?)

提交回复
热议问题