Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change bumper collisions to account for rubber #71

Open
sleddog opened this issue Oct 22, 2017 · 4 comments
Open

Change bumper collisions to account for rubber #71

sleddog opened this issue Oct 22, 2017 · 4 comments

Comments

@sleddog
Copy link
Owner

sleddog commented Oct 22, 2017

Currently the bumper collisions are treated as elastic collisions just like striking a mirror.

        ball = this.balls[i];
        //if potted, no collision with bumper
        if(!ball.potted) {
            if(ball.position.x > X_MAX-PREFS.bumperWidth-ball.radius || ball.position.x < 0+PREFS.bumperWidth+ball.radius) {
                    ball.velocity.x *= -1;
            }
            if(ball.position.y > Y_MAX-PREFS.bumperWidth-ball.radius || ball.position.y < 0+PREFS.bumperWidth+ball.radius) {
                    ball.velocity.y *= -1;
            }
        }
        ball.update();

Note the velocity is simply flipped. We should account for some velocity decrease after striking the rubber bumper. Also make this rubber bounce be a preference.

@kinnerapriyap
Copy link
Contributor

Hey! I'd like to take this up, if that's okay.
What coeff of restitution should I use with the rubber bumper and ball?
I'm not sure what you mean about making the rubber bounce a preference, so if you could explain that out a little bit, it'd be great.

@sleddog
Copy link
Owner Author

sleddog commented Oct 22, 2017 via email

kinnerapriyap added a commit to kinnerapriyap/pool that referenced this issue Oct 23, 2017
kinnerapriyap added a commit to kinnerapriyap/pool that referenced this issue Oct 23, 2017
@kinnerapriyap
Copy link
Contributor

I put in a range up to 5 for bumperBounce (least to most bounce) because you've used such a range for the rest of the preferences. Do let me know if you'd like a different range.
Using KE loss as a preference was a complication, because it would need to account to negative cases also. This seemed like a better option in terms of bounce visualisation while selecting preferences.

@sleddog
Copy link
Owner Author

sleddog commented Nov 2, 2017

@kinnerapriyap brining over your comment from the closed PR:
"The angle if off because the velocity parallel to the bumper has no force on it and remains the same. The velocity perpendicular is reduced because of loss in kinetic energy due to collision. So since only one component of velocity changes, the angle changes. Do let me know if you want me to make any changes to it."

I think if the angle stayed the same (or wasn't as a pronounced change) and only the velocity changed would be best. If you want to continue this, can you reopen the PR and tweak this behavior?

Playing in real life the ball collisions with bumpers does cause an angle change based on speed but it is very minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants