Angle Measurer in C#

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

    First you need to measure the distance between your points:

        public int Distance2D(int x1, int y1, int x2, int y2)
        {
    
            int result = 0;
            double part1 = Math.Pow((x2 - x1), 2);
    
            double part2 = Math.Pow((y2 - y1), 2);
            double underRadical = part1 + part2;
            result = (int)Math.Sqrt(underRadical);
    
           return result;
      }
    

提交回复
热议问题