我使用ProGAL找到三个球体的两个交叉点。
这是我的代码:
Point p0 = new Point(2,8,1);
Point p1 = new Point(5,9,17);
Point p2 = new Point(21,19,11);
Point p3 = new Point(7,4,1);
double r0 = p3.distance(p0);
double r1 = p3.distance(p1);
double r2 = p3.distance(p2);
Sphere s0 = new Sphere(p0, r0);
Sphere s1 = new Sphere(p1, r1);
Sphere s2 = new Sphere(p2, r2);
Point[] intersections = Sphere.getIntersections(s0, s1, s2);
for(Point point : intersections)
System.out.println(point.x() + " " + point.y() + " " + point.z());
这是输出:
8.748195083271948 1.1144249830330588 0.8525618604469422
-6.949424320444698 27.02495339639668 2.176457472808587
这些点都不接近实际点(7,4,1)
。
是因为
i)舍入错误?
ii)算法错误?
或
iii)我做错了什么?