private double CosAngel(int idx1, int idx2, int i)
{
double error = 0.00001;
Point p3 = new Point(_char_list[i].bbx.X + (_char_list[i].bbx.Width) / 2, _char_list[i].bbx.Y + (_char_list[i].bbx.Height) / 2);
Point p1 = new Point(_char_list[idx1].bbx.X + (_char_list[idx1].bbx.Width) / 2, _char_list[idx1].bbx.Y + (_char_list[idx1].bbx.Height) / 2);
Point p2 = new Point(_char_list[idx2].bbx.X + (_char_list[idx2].bbx.Width) / 2, _char_list[idx2].bbx.Y + (_char_list[idx2].bbx.Height) / 2);
if (_debug) Console.WriteLine(p1.X + " " + p1.Y + ";" + p2.X + " " + p2.Y + ";" + p3.X + " " + p3.Y + ";");
double x1 = p1.X;
double x2 = p2.X;
double x3 = p3.X;
double y1 = p1.Y;
double y2 = p2.Y;
double y3 = p3.Y;
if (x1 == x3 && x2 == x3)
return 180;
if (y1 == y3 && y2 == y3)
return 180;
double adotb = (x2 - x3) * (x1 - x3) + (y2 - y3) * (y1 - y3);
double tmp1 = (Math.Sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)) * Math.Sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3)));
double tmp2 = adotb / tmp1;
double angel = 0;
if (Math.Abs(Math.Abs(tmp2) - 1) < error) angel = 180;
else
{
angel = Math.Acos(adotb / tmp1);
angel = angel * 180 / Math.PI;
}
if (angel < 0)
return 180 + angel;
else return angel;
}