angle & direction after collision

C++

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 11769 Views - Last Post: 21 December 2009 - 04:09 PM Rate Topic: -----

#1 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

angle & direction after collision

Posted 13 December 2009 - 07:03 AM

Hi,

Im working on detecting collision of ball in parabolic motion with some other ball, recangle etc, what i have is

Quote

position of ball
speed
current angle
detected collision
collision position


and what i need is

Quote

angle
direction


after collision and , it need to work on all objects no matter what shape there are which is hard i think.

i tried doing this myself but i failed, so i dont have any woking or half-working code.

Is This A Good Question/Topic? 0
  • +

Replies To: angle & direction after collision

#2 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: angle & direction after collision

Posted 13 December 2009 - 10:35 AM

Is it 2-D collision like this?

Posted Image
Was This Post Helpful? 0
  • +
  • -

#3 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

Re: angle & direction after collision

Posted 13 December 2009 - 12:51 PM

well ball is much smaller than rectangle and usually jump into it becouse of speed but i think it doesnt matter so much, and yes collision looks sth like that you showed but ofc it can happen on whole recangle.
Was This Post Helpful? 0
  • +
  • -

#4 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: angle & direction after collision

Posted 13 December 2009 - 03:11 PM

check out this link http://www.peroxide....n/collision.pdf its hard going though!
Was This Post Helpful? 0
  • +
  • -

#5 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

Re: angle & direction after collision

Posted 13 December 2009 - 04:09 PM

Thanks for link, interesting, but it covers only "sliding collision" and "preventing object from going thru some other object it should collide" right ?
If so i need only angle and direction after collision sth like this http://en.wikipedia....astic_collision
ofc i tried those formulas from wiki but it wasnt working.
Was This Post Helpful? 0
  • +
  • -

#6 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: angle & direction after collision

Posted 14 December 2009 - 10:17 AM

Okay, so is this what you mean by angle of collision?

Posted Image

Also, what are the other possible shapes of objects? And what do you mean my direction of collision?

This post has been edited by bsaunders: 14 December 2009 - 10:18 AM

Was This Post Helpful? 0
  • +
  • -

#7 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: angle & direction after collision

Posted 14 December 2009 - 10:29 AM

By direction, do you mean the direction the object was moving in before it collided?
Was This Post Helpful? 0
  • +
  • -

#8 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

Re: angle & direction after collision

Posted 14 December 2009 - 11:51 AM

here is example of what i mean by direction:

if ball hits rectangle on UP or DOWN side only "vector.y" will change if LEFT or RIGHT the "vector.x" will change, but i think it will come from calculated angle.

and i found great site about what im trying to accomplish : http://graja.net/eks...Przeszkody.html its in poliss but it doesnt matter.

Quote

Also, what are the other possible shapes of objects


well all possible, look at that link i posted
Was This Post Helpful? 0
  • +
  • -

#9 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: angle & direction after collision

Posted 14 December 2009 - 12:16 PM

I'm having a hard time visualizing this. So you have an ellipse moving parabolically, and there are other objects in the path of that ellipse, and you want to find the angle and direction of the collision of the ellipse and the object, right? The animation on the link you provide had a ball moving on a straight path.

This post has been edited by bsaunders: 14 December 2009 - 12:17 PM

Was This Post Helpful? 0
  • +
  • -

#10 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: angle & direction after collision

Posted 14 December 2009 - 12:33 PM

@bsaunders

Basically what he is saying is that he wants the calculations to work out how an object will bouce from a certain angle, lets say you throw a ball at a wall.

If your throw it straight it will return on essentially the same angle, whereas if you throw it from the left it will bounce off at an angle.

Attached Image
So how to get directional vector B from directional vector A, after the collision with the plane.

I think :crazy:

@devcom
Can you give some code that you have tried?
Was This Post Helpful? 0
  • +
  • -

#11 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

Re: angle & direction after collision

Posted 14 December 2009 - 01:03 PM

ok, lets say i have nothing, and i want to create sth like that ball in that last link, what do you suggest ( i mean besides to know trig etc.)
if i will have sth like that ball i can do the rest
Was This Post Helpful? 0
  • +
  • -

#12 bsaunders  Icon User is offline

  • D.I.C Addict

Reputation: 44
  • View blog
  • Posts: 571
  • Joined: 18-January 09

Re: angle & direction after collision

Posted 14 December 2009 - 01:33 PM

You can start by creating a Ball class.
Was This Post Helpful? 0
  • +
  • -

#13 devcom  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-November 09

Re: angle & direction after collision

Posted 14 December 2009 - 02:04 PM

well i have it, i just need the calculations, no whole code
Was This Post Helpful? 0
  • +
  • -

#14 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: angle & direction after collision

Posted 14 December 2009 - 05:39 PM

Well, take the dot product of the first directional vector and the normal of the plane the object collided into

V = velocity vector

N = normal of plane

. = dot product

R = new vector


(V . N)*N

This projects V onto N, now to get a reflecting vector

R = 2*(V . N)*N - V

and getting a bounce vector

R = -2*(V . N)*N +V
Was This Post Helpful? 0
  • +
  • -

#15 PixelStation  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 44
  • Joined: 12-November 09

Re: angle & direction after collision

Posted 14 December 2009 - 08:40 PM

I love this book for all the motion and physics examples. Sometimes it can get a little hard to follow, but looking on google usually helps that.

Here's the link: clicky, then go to "Chapter 13: Playing God: Basic Physics Modeling", then to "5 Basic Ad Hoc Collision Response"

Edit: fixed the link

This post has been edited by PixelStation: 15 December 2009 - 08:58 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2