四边形面积公式
Formula for Quadrilateral area
我找不到确定具有四个顶点(点)的四边形面积的公式。谁的数学很强,可以帮忙算出 Java 的公式。非常感谢。
我只知道 'convex quadrilaterals are divided into two triangles by any of their diagonals'.
我们可以使用shoelace formula
计算任何多边形的顶点坐标
Java代码from here
public static double polygonArea(double X[], double Y[], int n)
{
// Initialize area
double area = 0.0;
// Calculate value of shoelace formula
int j = n - 1;
for (int i = 0; i < n; i++)
{
area += (X[j] + X[i]) * (Y[j] - Y[i]);
// j is previous vertex to i
j = i;
}
// Return absolute value
return Math.abs(area / 2.0);
}
对于四边形的特殊情况,我们可以写出没有循环的结果
Area = 0.5 * ((x[0]*y[1]+x[1]*y[2]+x[2]*y[3]+x[3]*y[0]) -
(x[1]*y[0]+x[2]*y[1]+x[3]*y[2]+x[0]*y[3]))
我找不到确定具有四个顶点(点)的四边形面积的公式。谁的数学很强,可以帮忙算出 Java 的公式。非常感谢。 我只知道 'convex quadrilaterals are divided into two triangles by any of their diagonals'.
我们可以使用shoelace formula
计算任何多边形的顶点坐标Java代码from here
public static double polygonArea(double X[], double Y[], int n)
{
// Initialize area
double area = 0.0;
// Calculate value of shoelace formula
int j = n - 1;
for (int i = 0; i < n; i++)
{
area += (X[j] + X[i]) * (Y[j] - Y[i]);
// j is previous vertex to i
j = i;
}
// Return absolute value
return Math.abs(area / 2.0);
}
对于四边形的特殊情况,我们可以写出没有循环的结果
Area = 0.5 * ((x[0]*y[1]+x[1]*y[2]+x[2]*y[3]+x[3]*y[0]) -
(x[1]*y[0]+x[2]*y[1]+x[3]*y[2]+x[0]*y[3]))