计算3点(x,y)的曲率

我有一个二维欧几里德空间。给出了三点。

例如(p2是中间点):

Point2D p1 = new Point2D.Double(177, 289);

Point2D p2 = new Point2D.Double(178, 290);

Point2D p3 = new Point2D.Double(178, 291);

现在,我想计算这三个点的曲率。

double curvature = calculateCurvature(p1, p2, p3);

这该怎么做?是否存在现有方法(没有Java外部库)?

  • 曲率:https : //en.wikipedia.org/wiki/曲率
  • Menger曲率:https: //en.wikipedia.org/wiki/Menger_curvature

回答:

对于Menger

Curvature,该公式就在Wikipedia文章中:

curvature = 4*triangleArea/(sideLength1*sideLength2*sideLength3)

您到底尝试了哪个代码?

给定3分,计算这4个值应该并不难。

以下是一些有用的方法:

/**

* Returns twice the signed area of the triangle a-b-c.

* @param a first point

* @param b second point

* @param c third point

* @return twice the signed area of the triangle a-b-c

*/

public static double area2(Point2D a, Point2D b, Point2D c) {

return (b.x-a.x)*(c.y-a.y) - (b.y-a.y)*(c.x-a.x);

}

/**

* Returns the Euclidean distance between this point and that point.

* @param that the other point

* @return the Euclidean distance between this point and that point

*/

public double distanceTo(Point2D that) {

double dx = this.x - that.x;

double dy = this.y - that.y;

return Math.sqrt(dx*dx + dy*dy);

}

没有更多的事情要做。警告:area2根据点的方向(顺时针或逆时针)返回带符号的双精度型。

以上是 计算3点(x,y)的曲率 的全部内容, 来源链接: utcz.com/qa/430859.html

回到顶部