我有一个二维欧几里得空间。给出三点。
例如(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/Curvature
- 门格尔曲率:https://en.wikipedia.org/wiki/Menger_curvature
对于门格尔曲率,公式是正确的there在维基百科文章中:
curvature = 4*triangleArea/(sideLength1*sideLength2*sideLength3)
您具体尝试了哪个代码?
考虑到你的 3 分,计算这 4 个值应该不会太难。
Here有一些有用的方法:
/**
* 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
返回一个带符号的双精度值,具体取决于点的方向(顺时针或逆时针)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)