Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411917 Posts in 69431 Topics- by 58477 Members - Latest Member: KriegsHetzer

June 11, 2024, 12:52:32 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)ball physics
Pages: [1]
Print
Author Topic: ball physics  (Read 1610 times)
Sigma
Level 1
*


View Profile WWW
« on: September 18, 2010, 06:19:58 AM »

Hi guys,
     can anyone give me a link or tutorial about collision detection and response between a slope and a ball? All helps are appreciated.

Thanks in advance...
Logged

increpare
Guest
« Reply #1 on: September 18, 2010, 06:30:46 AM »

Question 1: Have you googled much?
Question 2: Is there a reason you're not using a physics library for your language?
Question 3: 2D or 3D?
Question 4: Do you want to do bouncing, rolling, &c.?
Logged
Sigma
Level 1
*


View Profile WWW
« Reply #2 on: September 18, 2010, 06:45:30 AM »

i have googled much i couldnt get any tutorials or samples and i dont want to use a physics library and the reason is i have to recode all the remaining stuffs, and its 2D, i want bouncing and rolling on a slope.

 
Logged

biino
Guest
« Reply #3 on: September 18, 2010, 07:02:23 AM »

I don't exactly understand your reasoning not to use an existing library (an approach I'd recommend).

Check out http://procyclone.com/. It's the website for the physics engine development book I use. It's pretty good. The site has source code from the book (c++) but it might be hard to follow without the book.

Or check out the source for http://www.box2d.org/

Bino
Logged
nikki
Level 10
*****


View Profile
« Reply #4 on: September 18, 2010, 07:04:46 AM »

http://www.phy.uct.ac.za/demonline/virtual/slope.html

i typed "physics ball slope" in google image search and clicked the first image
Logged
bateleur
Level 10
*****



View Profile
« Reply #5 on: September 18, 2010, 07:31:28 AM »

Or check out the source for http://www.box2d.org/

Whilst this is generally a very good idea I think it's probably overkill for his actual requirements. Ball/slope is very easy physics compared to the general-case rigid body stuff that Box2D simulates.

Box2D's code is surprisingly elegant for what it does, but it's still tricky stuff to understand, even for someone confident with both AS3 and Newtonian mechanics.
Logged

st33d
Guest
« Reply #6 on: September 18, 2010, 08:08:13 AM »

For a beginner's introduction to ball vs line physics I can recommend Tony Pa's old vector tutorial:

http://www.tonypa.pri.ee/vectors/tut07.html

Once you've mastered the basic vector math he's outlined in it, then you can move on to more advanced physics engines. It's very easy to understand and is a great primer on vector math.

It's a tutorial I keep coming back to and one grew my geometry objects out of (although you would barely recognise the connection nowadays).

After you've tackled that, you'll want to learn "separating axis theorem". That will set you up for polygon collisions.

And if you want to do billiard ball collision, I posted a thread on an old forum here:

http://processing.org/discourse/yabb2/YaBB.pl?num=1201461240

It's a fairly basic version of billiard ball collision, but it does work.

For simply testing a collision between a circle and a line, then you can use the proximity() method in my Line object here:

http://github.com/st33d/red-rogue/blob/master/src/com/robotacid/geom/Line.as

Resolving the collision is something you'll have to figure out yourself - but as I said, work through the Tony Pa tutorial and you'll have a good foundation to grow from.
Logged
Sigma
Level 1
*


View Profile WWW
« Reply #7 on: September 19, 2010, 02:43:22 AM »

I have one more basic question sorry for asking such noob questions

AB is a line segment whose lenth is 50pixels and AB starts at 10,10 so the end point B of line segment AB is at 60,10.Now i rotates the line 40 deg with A as pivot point; now how can i find the end point B after rotation?

Thanks in advance
Logged

st33d
Guest
« Reply #8 on: September 19, 2010, 03:59:27 AM »

Observe my line class again. Look for the method called rotateB. Convert your degrees to radians

radians = degrees * (Math.PI / 180)

use rotateB(radians)
Logged
Sigma
Level 1
*


View Profile WWW
« Reply #9 on: September 19, 2010, 09:57:08 AM »

Thanks man...
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic