Angle Measurer in C#

前端 未结 6 1789
北恋
北恋 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:17

    similar to In silico's answer, you can use a combination of a dot product and cross product to get the angle, and not just the undirected angle.

    where a and b are vectors run from the point you want to calculate the angle from to the corners of your picture boxes, respectively.

    a*b = |a| |b| cos theta

    axb = |a| |b| sin theta

    axb / a*b = tan theta

    atan2(axb, a*b) = theta

提交回复
热议问题