java - Collision Response of ball at Corners of rectangle -


I have a fixed rectangle when the ball is at the top of a triangle, I have a tangent (rectangular peak) at the point of contact Let's count. Then I match the tangent to rotate the velocity wheel, flip the y value of velocity and turn it back. Here is my code for the top-left corner:

  double c1x = rec.x-ball.getX (); Double c1y = rec-ball.getY (); If (C1 * C1 + C2 * C2 and Lt; Ball.Getrediais) * Ball.Getrediais ()) {Double Angle = Monastery.T.T 2 (-C1X, C1A); Angle angle created by tangent vector 2D v = ball.velocity.rotate (angle); // Rotate the velocity vector by 'Wayne', if (v.y & lt; 0.0f) // ball is already getting away from corner returns; v.setY (-v.y); // flip y ball.vivecty = v.rotate (-gangle); // Return to turn back; }   

But this code does not work when the ball is attacked in the corner, it gets trapped, moves on the top edge and then falls, does not bounce back. Am I correcting it?

By making some assumptions about your conventions, I suggest:

  Double Angle = Math Stenosis 2 (-C1x, -C1);   

If that does not work, we can do some experiment to know what's really going on.

Edit:

Okay, we should raise this with simple solutions. Try these experiments:

1) Set (0,1) and confirm that the ball runs straight after the collision.

2) Set the Velocity (-1,1) and verify that the ball goes up and down.

If those tasks are expected, choose a path that you would expect to behave in a normal way, such as rising up and down on the left side, but slightly left, then your Run it through the code but print all the values ​​in the collision and let us know what they are. This is at the beginning of the values ​​of at least c1x , c1y , angle , and velocity [/ code] and after each rotation . Perhaps notice where screams are, and if you will not.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -