gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 09:38:56 25 4
gpt4 key购买 nike

我有一个二维欧氏空间。给出三点。

例如(p2为中点):

Point2D p1 = new Point2D.Double(177, 289);
Point2D p2 = new Point2D.Double(178, 290);
Point2D p3 = new Point2D.Double(178, 291);

现在我想计算 curvature对于这三点。

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

如何做到这一点?有没有现成的方法(没有java外部库)?

最佳答案

对于门格尔曲率,公式是对的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 返回带符号的 double ,具体取决于您的点的方向(顺时针或逆时针)。

关于java - 计算 3 个点 (x,y) 的曲率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41144224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com