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));
}
}
添加回答
舉報