Getting values from mouse hover on a class object C#

后端 未结 1 704
鱼传尺愫
鱼传尺愫 2021-01-21 14:55

I\'ve a txt file with a 360 numbers, I must read all of these and draw a kind of Disc made of FillPie eachone colored in scale of grey due to the value of the list. Until here e

相关标签:
1条回答
  • 2021-01-21 15:50

    Eventually it looks as if all you want is a function to get the angle between the mouse position and the center of the disc..

    Here is a function to calculate an angle given two points:

    double AngleFromPoints(Point pt1, Point pt2)
    {
        Point P = new Point(pt1.X - pt2.X, pt1.Y - pt2.Y);
        double alpha = 0d;
        if (P.Y == 0) alpha = P.X > 0 ? 0d : 180d;
        else
        {
            double f = 1d * P.X / (Math.Sqrt(P.X * P.X + P.Y * P.Y));
            alpha = Math.Acos(f) * 180d / Math.PI; 
            if (P.Y > 0) alpha = 360d - alpha;
        }
        return alpha;
    }
    
    0 讨论(0)
提交回复
热议问题