1 回答
TA贡献1878条经验 获得超4个赞
您正在将p1and声明p2为Vec2D数组,并且您的方法定义指定了Vec2D数组返回类型。但是,在您的方法中,您返回一个单一的Vec2D对象。
一个潜在的解决方案:
public class SomeJavaClassName
{
ArrayList<Vec2D> points = new ArrayList<String>();
// Other methods, properties, variables, etc.,
// some of which would populate points
public Vec2D getCasteljauPoint(int r, int i, double t) {
// points[] is declared outside just like in the C# code
if(r == 0) return points.get(i);
Vec2D p1 = getCasteljauPoint(r - 1, i, t);
Vec2D p2 = getCasteljauPoint(r - 1, i + 1, t);
return new Vec2D(((1/2) * p1.getX + (1/2) * p2.getX), ((1/2)
* p1.getY + (1/2) * p2.getY));
}
}
添加回答
举报