Fun-Motion Physics Games Forum  

Go Back   Fun-Motion Physics Games Forum > Developers > Feedback Request

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-17-2009, 09:53 PM
Neophyte_ Neophyte_ is offline
Junior Member
 
Join Date: Feb 2009
Location: Hell
Lightbulb Verlet Based Physics Engine

Hi,

im new to C# and i never wrote anything with physics
Im working on a simple verlet based engine with dynamic constraints.
Thats what I did so far:
http://www.youtube.com/watch?v=0iBlm2QD4V0
But i dont know how to check for collisions between the particles / constraints.
I have an idea but i dont know if it will work:


I think i know how to calculate the impulse on collision by using that...
...but i even dont know if its suitable.

btw Im 15 and (im from Germany) my english isnt that good
Reply With Quote
  #2  
Old 02-17-2009, 09:56 PM
lafe's Avatar
lafe lafe is offline
Senior Member
 
Join Date: Aug 2008
Location: i can tell you, but then ill have to kill you
Default

Quote:
Originally Posted by Neophyte_ View Post
Hi,

im new to C# and i never wrote anything with physics
Im working on a simple verlet based engine with dynamic constraints.
Thats what I did so far:
http://www.youtube.com/watch?v=0iBlm2QD4V0
But i dont know how to check for collisions between the particles / constraints.
I have an idea but i dont know if it will work:


I think i know how to calculate the impulse on collision by using that...
...but i even dont know if its suitable.

btw Im 15 and (im from Germany) my english isnt that good
thats realy good!
Reply With Quote
  #3  
Old 02-17-2009, 09:58 PM
Neophyte_ Neophyte_ is offline
Junior Member
 
Join Date: Feb 2009
Location: Hell
Default

Thanks

Ok, Ill try it tomorrow :P

Last edited by Neophyte_; 02-17-2009 at 10:13 PM..
Reply With Quote
  #4  
Old 02-20-2009, 10:34 PM
meow-muffin's Avatar
meow-muffin meow-muffin is offline
Senior Member
 
Join Date: Feb 2008
Location: California
Default

Nice sim, defiantly needs collision detection though. I could really see this become fairly successful.
Reply With Quote
  #5  
Old 02-20-2009, 11:04 PM
Neophyte_ Neophyte_ is offline
Junior Member
 
Join Date: Feb 2009
Location: Hell
Default

Im still working on the collision detection :P
Not that easy as I thought it would be...

Last edited by Neophyte_; 02-21-2009 at 01:23 AM..
Reply With Quote
  #6  
Old 02-21-2009, 07:13 AM
Wrestler#1's Avatar
Wrestler#1 Wrestler#1 is offline
Senior Member
 
Join Date: Feb 2007
Location: 7
Default

Whoa! You are 15 and are THAT good at physics-programming?
I am amazed!

Alter, im Ernst: Bist du auf einer Privatschule oder sowas? Bin nämlich auf dem Gymnasium und hab deine Gedankengänge nicht verstanden
Reply With Quote
  #7  
Old 02-21-2009, 08:59 AM
Neophyte_ Neophyte_ is offline
Junior Member
 
Join Date: Feb 2009
Location: Hell
Default

OMG

Thats my first try!!
I read articles and wikipedia about the maths for hours...


Das nimmst du mir jetzt vllt nicht ab, aber ich gehe auf ne Realschule (was mich total ankotzt, bin ende der 7ten aufm Gym zu faul geworden =/). Der Gedankengang ist folgender:
Du prüfst für jeden Partikel auf jede Feder. Also nimmst du die Punkte A, B (Punkte zwischen denen die Feder "gespannt" ist), PartikelPosition und PartikelPosition_Alt (also bei der Verlet Integration arbeitest du anstatt mit Geschw. nur mit der aktuellen Position, der Beschleunigung (also der Gravitation in dem Fall) und der Position der letzten Berechnung für den Partikel.
Jetzt kommts, ich rechne den Winkel zwischen den Eckpunkten der Feder aus, relativ zur vertikalen. Ich brauche noch die Längen A-B A-PartikelPosition A-PartikelPosition_Alt.
Nun kann ich alle 4 Punkte um den Winkel drehen, sodass die Gerade AB vertikal liegt. Wenn jetzt die alte PartikelPosition nicht auf der selben Seite liegt wie die neue PartikelPosition, also eine Kollision vorhanden ist, muss ich den Impuls ausrechnen per Vektor und eben 50/50 auf beide Objekte anwenden...

Joa das wars eig schon :P

Last edited by Neophyte_; 02-21-2009 at 10:16 AM..
Reply With Quote
  #8  
Old 03-27-2009, 02:48 AM
LuizZak's Avatar
LuizZak LuizZak is offline
Member
 
Join Date: Jul 2007
Location: Brazil
Default

In order to check for contraints-particles collision, you need to calculate the dot product (normalize the start point, first) of the particle over the constraint, then calculate the distance between the result and the particle's position. If it's less than the particle radius, that they're colliding!

More info at google.

It's good to see I'm not the only young programmer 'round here
Reply With Quote
  #9  
Old 06-20-2009, 10:07 PM
milke492 milke492 is offline
Junior Member
 
Join Date: Jun 2009
Default premium quality wigs

Specializing in lace front wigs, lace wigs premium quality wigs, full lace front wigs and synthetic wigs. Every wig in our luxurious collection is made with best-in-class Remy hair, synthetic hair, cap design, and construction.
Reply With Quote
  #10  
Old 06-22-2009, 09:03 PM
Nate The Great Nate The Great is offline
Senior Member
 
Join Date: Apr 2009
Default

yeah thats really cool. I am also 15 and also struggling to do pointmass-constraint collisions in my physics engine I got some formulas for if the particle passes over the constraint but I dont have any for if the constraint passes over the particle.

here is what I have so far but tbh I am struggling understanding it

its in bmax btw

Code:
If v.ID <> c.v1.ID And v.ID <> c.v2.ID Then
				Local dx# = v.x-v.ox
				Local dy# = v.y-v.oy
				Local dist# = Sqr(dx*dx + dy*dy)
				If dist# = 0 Then dist = 1 And dx = 0 And dy = 0
				
					If lines_intersect(v.ox,v.oy,v.x+dx/dist*2,v.y+dy/dist*2,c.v1.x,c.v1.y,c.v2.x,c.v2.y) Then	'did the point pass over the constraint?
						Local vex# = v.x-Intersection_x
						Local vey# = v.y-Intersection_y
						Local mw1# = c.v2.mass/c.v1.mass
						Local mw2# = c.v1.mass/c.v2.mass
						Local d1#
						Local d2#
						If c.v1.x=c.v2.x Then
							d1 = Abs(c.v1.y-Intersection_y)
							d2 = Abs(c.v2.y-Intersection_y)
						Else
							d1 = Abs(c.v1.x-Intersection_x)
							d2 = Abs(c.v2.x-Intersection_x)
						EndIf
						Local tm# = c.v1.mass + c.v2.mass + v.mass
						Local w1# = 1
						If d1 <> 0 Then w1# = d2/d1
						Local w2# = 1
						If d2 <> 0 Then w2# = d1/d2
						Local fx# = Intersection_x + vex*(v.mass/tm) + (c.v1.x-c.v1.ox)*(c.v1.mass/tm) + (c.v2.x-c.v2.ox)*(c.v2.mass/tm)
						Local fy# = Intersection_y + vey*(v.mass/tm) + (c.v1.y-c.v1.oy)*(c.v1.mass/tm) + (c.v2.y-c.v2.oy)*(c.v2.mass/tm)
						Local dfx# = fx-Intersection_x
						Local dfy# = fy-Intersection_y
						DrawOval fx-4,fy-4,8,8
						
						ccollide.Create(c:constraint,v:verlet,c.v1.x + (w1*mw1)*dfx,c.v1.y + (w1*mw1)*dfy,c.v2.x + (w2*mw2)*dfx,c.v2.y + (w2*mw2)*dfy,fx,fy)
maybe you could extract some useful maths out of this as long as you have a decent linesintersect function
Reply With Quote
  #11  
Old 06-22-2009, 10:09 PM
samysam's Avatar
samysam samysam is offline
Senior Member
 
Join Date: Mar 2008
Location: Up on melancholy hill
Default

Quote:
Originally Posted by Nate The Great View Post
I am also 15
I think it's irrelevant how old you are so you can stop trying to show off by saying you are 15.

Same with the other guy.

(sorry just not in the best of moods today...)
Reply With Quote
  #12  
Old 06-22-2009, 10:12 PM
UberGimp's Avatar
UberGimp UberGimp is offline
Senior Member
 
Join Date: Oct 2008
Default

Quote:
Originally Posted by samysam View Post
I think it's irrelevant how old you are so you can stop trying to show off by saying you are 15.

Same with the other guy.

(sorry just not in the best of moods today...)
I don't care. I think it's impressive that he can do that shit while being 15.
Hell, im 17 i can't even look at it without getting a headache.
Reply With Quote
  #13  
Old 06-22-2009, 10:20 PM
Nate The Great Nate The Great is offline
Senior Member
 
Join Date: Apr 2009
Default

I wasnt bragging or anything.. I just thought it was a coincidence... and I didnt know there were many other 15 year olds out there that knew anything about programming.
Reply With Quote
  #14  
Old 06-23-2009, 12:39 AM
samysam's Avatar
samysam samysam is offline
Senior Member
 
Join Date: Mar 2008
Location: Up on melancholy hill
Default

Yeah, sorry bout that...

But programing aint hard really ubergimp once you get used to a language it can make a lot of sence and can be very fun to write.
Reply With Quote
  #15  
Old 06-23-2009, 05:38 PM
STEVIE G STEVIE G is offline
Senior Member
 
Join Date: Mar 2007
Location: Glasgow, Scotland
Default

@ Nate,

Quote:
If dist# = 0 Then dist = 1 And dx = 0 And dy = 0
The logic doesn't look very sound here ..

Stevie
Reply With Quote
  #16  
Old 06-24-2009, 03:30 AM
Nate The Great Nate The Great is offline
Senior Member
 
Join Date: Apr 2009
Default

hey stevie.. long time no see

and thats just an error checking line to prevent divided by 0 errors later on. It is only set off if the user interferes with the engine internally and messes something up to make the dist = 0 at that point (which it SHOULD never be but sometimes is.) I know it is still flawed but that is the only way I have been able to avoid a million integer divided by 0 errors.
Reply With Quote
  #17  
Old 12-02-2009, 09:04 PM
D.gaine's Avatar
D.gaine D.gaine is offline
Junior Member
 
Join Date: Oct 2009
Location: United States
Default Verlet Based Physics Engine

Is there more information available regarding the Mercedes-Benz 190E Turbo Diesel Engine Swap that appeared in your latest magazine. Thanks for any information.
Reply With Quote
  #18  
Old 12-02-2009, 09:14 PM
Gamerguy99's Avatar
Gamerguy99 Gamerguy99 is offline
Senior Member
 
Join Date: Aug 2009
Location: Shhh! It's a secret!
Default

*sigh* (ten letters)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:06 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.