【问题标题】:Minimum Bounding Sphere for a Single 3D Triangle单个 3D 三角形的最小边界球体
【发布时间】:2023-03-23 06:50:01
【问题描述】:

--原帖--

我正在尝试计算 3 维三角形的最小边界球。 三角形由点point0,point1,point2给出。

下面的代码是从http://en.wikipedia.org/wiki/Circumscribed_circle#Barycentric_coordinates_from_cross-_and_dot-products创建的

对于样本输入(0,0,10),(0,10,0),(10,0,0),下面的代码给出:

radius = 8.164967,正确(使用谷歌Sketchup绘制模型验证)。

minSphereCenter = (10, 3.333..., 1.111...),这是不正确的。

正确的中心点应该是 (3.333..., 3.333..., 3.333...)。


我做错了什么?

注意:我知道这不会给出钝角三角形的最小边界球。

--解决方案--

class Triangle{
  Vector3f point0, point1, point2;

  Vector3f minSphereCenter;

  float minSphereRadius;

  private void calculateMinimumBoundingSphere() {
    minSphereRadius=
      (point0.distance(point1)*point1.distance(point2)*point2.distance(point0))/
                (2*(new Vector3f().cross(new Vector3f().sub(point0, point1), new Vector3f().sub(point1, point2)).length()));

    float divisor=2*(new Vector3f().cross(new Vector3f().sub(point0, point1), new Vector3f().sub(point1, point2)).lengthSquared());

    float
      i=point1.distanceSquared(point2)*new Vector3f().sub(point0, point1).dot(new Vector3f().sub(point0, point2))/
        divisor,

      j=point0.distanceSquared(point2)*new Vector3f().sub(point1, point0).dot(new Vector3f().sub(point1, point2))/
        divisor,

      k=point0.distanceSquared(point1)*new Vector3f().sub(point2, point0).dot(new Vector3f().sub(point2, point1))/
        divisor;

      minSphereCenter=new Vector3f(point0).scale(i).add(new Vector3f(point1).scale(j)).add(new Vector3f(point2).scale(k));

      System.out.println(minSphereCenter);
      System.out.println(minSphereRadius);

    }

【问题讨论】:

    标签: java geometry computational-geometry minimum-size


    【解决方案1】:

    我发现了问题:最初的 minSphereCenter 代码使用了一个 scaleAdd() 函数,我认为它的工作原理类似于 addScale() 函数。

    原始问题已使用解决方案进行了编辑。

    【讨论】:

      猜你喜欢
      • 2011-03-11
      • 2017-02-19
      • 1970-01-01
      • 2018-12-20
      • 2012-02-22
      • 1970-01-01
      • 2012-08-29
      • 1970-01-01
      • 2011-01-24
      相关资源
      最近更新 更多