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

例如(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 外部库)?
  • 曲率: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 返回一个有符号的 double 值,这取决于点的方向(顺时针或逆时针)。

    10-08 12:51