![]() |
|
#1
|
|||
|
|||
|
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 ![]() |
|
#2
|
||||
|
||||
|
Quote:
|
|
#3
|
|||
|
|||
|
Thanks
![]() Ok, Ill try it tomorrow :P Last edited by Neophyte_; 02-17-2009 at 10:13 PM.. |
|
#4
|
||||
|
||||
|
Nice sim, defiantly needs collision detection though. I could really see this become fairly successful.
![]() |
|
#5
|
|||
|
|||
|
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.. |
|
#6
|
||||
|
||||
|
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 ![]() |
|
#7
|
|||
|
|||
|
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.. |
|
#8
|
||||
|
||||
|
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 ![]() |
|
#9
|
|||
|
|||
|
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.
|
|
#10
|
|||
|
|||
|
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) |
|
#11
|
||||
|
||||
|
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...) |
|
#12
|
||||
|
||||
|
Quote:
Hell, im 17 i can't even look at it without getting a headache. |
|
#13
|
|||
|
|||
|
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.
|
|
#14
|
||||
|
||||
|
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. |
|
#15
|
|||
|
|||
|
@ Nate,
Quote:
Stevie |
|
#16
|
|||
|
|||
|
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. ![]() |
|
#17
|
||||
|
||||
|
Is there more information available regarding the Mercedes-Benz 190E Turbo Diesel Engine Swap that appeared in your latest magazine. Thanks for any information.
|
|
#18
|
||||
|
||||
|
*sigh* (ten letters)
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|