本文介绍了计算3点(x,y)的曲率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a two dimensional euclidean space. Three points are given.

例如(p2是中间点):

For example (p2 is the middle point):

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

现在,我想针对这三点计算曲率.

Now i want to calculate the curvature for these three points.

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

如何执行此操作?是否存在现有方法(没有Java外部库)?

How to do this?Ist there a existing method (no java external libraries)?

  • Curvature: https://en.wikipedia.org/wiki/Curvature
  • Menger Curvature:https://en.wikipedia.org/wiki/Menger_curvature

推荐答案

对于Menger曲率,公式是正确的:

For the Menger Curvature, the formula is right there in the Wikipedia article :

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

您完全尝试了哪个代码?

Which code did you try exactly?

鉴于您的3分,计算这4个值应该并不难.

It shouldn't be too hard to calculate those 4 values given your 3 points.

此处是一些有用的方法:

/**
 * 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会根据点的方向(顺时针或逆时针)返回带符号的双精度符号.

There's not much more to do. Warning : area2 returns a signed double, depending on the orientation of your points (clockwise or anticlockwise).

这篇关于计算3点(x,y)的曲率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 13:49