请教大神关于C#直线求夹角的问题。。
已知八个点的坐标。。分别依次求出八个点连成的直线的斜率。。通过斜率求直线之间按逆时针方向形成的夹角。。。。代码如下。。:double[] X = new double[] {15,24,32,40,39,35,28,16 };
double[] Y = new double[] {40,35,34,38,50,51,50,53 };
double[] K = new double[7];
double[] jiajiao = new double[6];
int i = 0, j=1;
double k,max,min,angle,hudu,result;
do
{
k = (Y[i+1]-Y[i])/(X[i+1]-X[i]);
K[i] = k;
Console.WriteLine("k" + i.ToString() + "={0}", K[i]);
i++;
}
while (i <= 6);
do
{
result = ((K[j] - K[j - 1]) / (1 + K[j] * K[j - 1]));
hudu = Math.Atan(result);
angle = 180 * (hudu/Math.PI);
jiajiao[j-1] = angle;
Console.WriteLine("jiajiao" + j.ToString() + "={0}", jiajiao[j - 1]);
j++;
}
while (j <= 6);
运行出来之后直线的斜率是正确的。。但是夹角不对。。。请教一下。。!