如何在两个3d矢量之间使用lerp? 我用这个方法用于2D载体:3D矢量线性插值
public Vector2d lerp(Vector2d other, double speed, double error) {
if (equals(other) || getDistanceSquared(other) <= error * error)
return other;
double dx = other.getX() - this.x, dy = other.getY() - this.y;
double direction = Math.atan2(dy, dx);
double x = this.x + (speed * Math.cos(direction));
double y = this.y + (speed * Math.sin(direction));
return new Vector2d(x, y);
}
注意:这是不完全的“线性内插”;此方法将以恒定速率进行内插,这正是我想要的。
我想要做到这一点,但为第三维增加了一个z组件。我怎样才能做到这一点?