我正在用 Java 制作台球游戏。我使用本指南来解决冲突。在测试过程中,我注意到碰撞后两个碰撞池球之间的速度更大。额外速度的数量似乎是 0%-50%。直射约 0%,极宽射约 50%。我假设组合速度将保持不变。是我的代码还是我对物理的理解是错误的?
private void solveCollision(PoolBall b1, PoolBall b2) {
System.out.println(b1.getMagnitude() + b2.getMagnitude());
// vector tangent to collision point
float vTangX = b2.getY() - b1.getY();
float vTangY = -(b2.getX() - b1.getX());
// normalize tangent vector
float mag = (float) (Math.sqrt((vTangX * vTangX) + (vTangY * vTangY)));
vTangX /= mag;
vTangY /= mag;
// get new vector based on velocity of circle being collided with
float NVX1 = b1.getVector().get(0) - b2.getVector().get(0);
float NVY1 = b1.getVector().get(1) - …Run Code Online (Sandbox Code Playgroud)