Angle Measurer in C#

前端 未结 6 1886
北恋
北恋 2020-12-20 09:53

I want to make a tool that can measure angles between two user defined spots on a form. I have no code to do this at the moment, so any code would be appreciated.

Th

6条回答
  •  误落风尘
    2020-12-20 10:33

    To measure an angle you need three points or a base direction.

    Math.Atan2(y, x) can be used to measure the angle to the x-axis.

    Note that y is the first param and not the second. Unlike other versions of this function it is safe with x=0

    To transform the result which is given in radians to degrees you need to multiply with (180/Math.PI)

提交回复
热议问题