public int test(point a,point b,point c)
{
//......
}方法如何实现,我感觉我对不起我小学体育老师.C#角度两条直线point
{
//......
}方法如何实现,我感觉我对不起我小学体育老师.C#角度两条直线point
解决方案 »
- asp.net发邮件的问题?óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
- 关于邮件群发 中间间隔几秒再发 的改怎么写
- 做好CS系统需要知道哪些知识啊!!
- C#读二进制文件的问题.
- C#反射,直接调用正常,封装到一个类库中间接调用出错。请高手帮忙
- 如何把FREETEXTBOX组件添加到WEB窗体
- C# Panel全屏后,任务栏部分不能全部占满
- crystl report for .net,有没有支持OLAP版本的?
- Datagrid中如何保存包含多个表的Dataset至数据库.(附代码,请指教)
- 请问C#如何操作OLE对象
- 100分向大家请教c# webfrom 打印的问题
- 建立学生管理系统中运行这种错误怎么解决?
ac相对x轴的角度是a1 = arc tan k1
同理,k2 = (b.y - c.y) / (b.x - c.x)
a2 = arc tan k2
角度acb = a1 + a2
公式
static float AngleInDegree(System.Drawing.Point p1, System.Drawing.Point p2, System.Drawing.Point p3)
{
System.Drawing.Point p12 = Normalize(Subtract(p1, p2));
System.Drawing.Point p32 = Normalize(Subtract(p3, p2));
return (float)(Math.Acos(Dot(p12, p32)) * 180 / Math.PI);
} static float Dot(System.Drawing.Point p1, System.Drawing.Point p2)
{
return p1.X * p2.X + p1.Y * p2.Y;
} static System.Drawing.Point Subtract(System.Drawing.Point p1, System.Drawing.Point p2)
{
return new System.Drawing.Point(p1.X - p2.X, p1.Y - p2.Y);
} static System.Drawing.Point Normalize(System.Drawing.Point p)
{
int length = (int)Math.Sqrt(p.X * p.X + p.Y * p.Y);
if (length < 10e-6) throw new ArgumentException();
return new System.Drawing.Point(p.X / length, p.Y / length);
} class Program
{
static void Main(string[] args)
{
//调用类库:
Point a = new Point { x = 0, y = 0};
Point b = new Point { x = 10, y = 0};
Point c = new Point { x = 0, y = 10};//2*Math.Sqrt(3) };
double[] result = Angle.getAllAngle(a, b, c);
Console.WriteLine(string.Format("a:{0}度, b:{1}度, c:{2}度", result[0], result[1], result[2]));
Console.Read();
}
}
//类库:
public struct Point
{
public double x;
public double y;
}
public static class Angle
{
public static double[] getAllAngle(Point a, Point b, Point c)
{
double[] result = new double[3];
result[0] = getIntersectionAngle(b, c, a);
result[1] = getIntersectionAngle(a, c, b);
result[2] = getIntersectionAngle(a, b, c);
return result;
}
public static double getIntersectionAngle(Point a, Point b, Point Intersection)
{
Point tempPoint1 = new Point { x = Intersection.x - a.x, y = Intersection.y - a.y};
Point tempPoint2 = new Point { x = Intersection.x - b.x, y = Intersection.y - b.y};
double temp = tempPoint1.x * tempPoint2.x + tempPoint1.y * tempPoint2.y;
double temp2 = Math.Sqrt(Math.Pow(tempPoint1.x, 2) + Math.Pow(tempPoint1.y, 2));
double temp3 = Math.Sqrt(Math.Pow(tempPoint2.x, 2) + Math.Pow(tempPoint2.y, 2));
double tempCos = temp / (temp2 * temp3);
double result = Math.Acos(tempCos);
return Math.Round(((180 * result) / Math.PI),1);
}
}