• Content count

  • Joined

  • Last visited

Community Reputation

144 Neutral

About FreeDebreuil

  • Rank
  1. Stability problem

    Hmmm.... I don't under stand Newton’s Law of Restitution for Instantaneous Collisions with No Friction. Guess I'll have to read Chris Hecker's articles again [dead]. SAT is seperating axis therom (Google!). This is the tutorial I'm using I'll try rewriting parts of the code, that always works. [grin] Thanks for you help! [Edited by - FreeDebreuil on May 10, 2006 7:12:36 PM]
  2. Stability problem

    I'm using the ratio out of one, because, say both of the objects had a mass of 100,000. If you divide the total force by 100,000 it would hardly affect each of the objects and they would pass through each other. Maybe I'm understanding this wrong or something... (btw - I'm using inverse masses) In my simulation, the moment of inertia is incorrect. Most of the objects I have are Squares and hexagons and stuff, but I have noticed that on objects other than those, it doesn't work. I was thinking of weighting each of the points with the length of the surrounding lines (I'm using SAT, so there's only convex polygons). Also, is there any way to make concave polygons with SAT? I was thinking of piecing a concave polygon together with a bunch of convex ones. The AddForce (now Add Acceleration[smile]) just applies a force to a temporary vector, then applies it every time I move the polygon (every tick). Once it's added, it clears the temp vector and starts over again. Is this what could be screwing it up? I was looking at my code for finding a contact point. It usually finds the right one, but in special cases, (two flat edges, two pointy edges) it won't work. The physics app your making sounds great! Thanks!
  3. Stability problem

    Whoops! Sorry about the naming. [grin] The ratios are how heavy one polygon is compared to the other polygon (out of 1). The MOE is the moment of inertia (the length between the COM and all the points, added together). The center of mass is actually in world space, it's a bit screwed up in that respect, but it works fine (you just change the COM along with everything else when you translate the points). Thanks for the reply!
  4. Stability problem

    I made a 2D physics app based on Oliver Renault’s tutorial, but the collision response isn’t working. If there are two or three objects on top of each other the program explodes. I’ve tried adding more damping, but then the objects don’t bounce off each other, and it still once in a while explodes. Any help appreciated! BTW - this is the method for collision response, I’ve tried to make it like Chris Hecker’s tutorials. public static void Respond( Polygon a, Polygon b, float deltaTime, Vector2 cP, Vector2 mtdN, float aRatio, float bRatio) { //------------------------------------------------------------------------------------------------------ //Pre-computations //------------------------------------------------------------------------------------------------------ float friction = (a.Material.Friction + b.Material.Friction) * 0.5F; float bounce = (a.Material.Bounce + b.Material.Bounce) * 0.5F; Vector2 aOB = cP - a.COM; Vector2 aOBNormal = new Vector2(-aOB.Y, aOB.X); Vector2 aOBn = Vector2.Normalize(aOB); Vector2 aOBnNormal = new Vector2(-aOBn.Y, aOBn.X); Vector2 bOB = cP - b.COM; Vector2 bOBNormal = new Vector2(-bOB.Y, bOB.X); Vector2 bOBn = Vector2.Normalize(bOB); Vector2 bOBnNormal = new Vector2(-bOBn.Y, bOBn.X); //Angular Velocity Vector2 aAV = aOBNormal * a.Rotation; Vector2 bAV = bOBNormal * b.Rotation; //Added Velocity Vector2 aAddV = aAV + a.Velocity; Vector2 bAddV = bAV + b.Velocity; //Linear Velocities Vector2 LV = -aAddV + bAddV; //------------------------------------------------------------------------------------------------------ // Friction and bounce //------------------------------------------------------------------------------------------------------ Vector2 mtdNNorm = new Vector2(-mtdN.Y, mtdN.X); Vector2 dFriction = Vector2.Dot(mtdNNorm, LV) * mtdNNorm; Vector2 dBounce = Vector2.Dot(mtdN, LV) * mtdN; LV = (dFriction * friction) + (dBounce * bounce); //------------------------------------------------------------------------------------------------------ // Applied velocity //------------------------------------------------------------------------------------------------------ //Applied Angular Velocities float aAVApply = Vector2.Dot(aOBnNormal, LV); float bAVApply = Vector2.Dot(bOBnNormal, -LV); //Applied Linear Velocity Vector2 aLVApply = Vector2.Dot(aOBn, LV) * aOBn; Vector2 bLVApply = Vector2.Dot(bOBn, -LV) * bOBn; //------------------------------------------------------------------------------------------------------ // Apply forces //------------------------------------------------------------------------------------------------------ //Apply Rotation a.AddForce(aAVApply * aRatio / a.MOE); b.AddForce(bAVApply * bRatio / b.MOE); //Apply linear velocity a.AddForce(aLVApply * aRatio); b.AddForce(bLVApply * bRatio); }
  5. Problems with physics engine...

    thanks! the pdf is really great!
  6. Problems with physics engine...

    I'm making a physics engine, but there's problems when objects are stacked on top of each other. The engine moves penenterating objects out of each other, then applies a force to then them bounce/spin away. The objects are moved apart, but they are now penenterating with the object above/below them. Is there anyway around this? I was thinking maybe if I used swept collision detection it would detect right before they colided, but I'm not sure how to get swept collision detection for SAT (I've tried a few times, could anyone point me in the right direction?). Thanks is advance!
  7. Springs

    Wow, thanks guys (or girls ;) )... Great site here!
  8. Springs

    Does anyone know a simple way to calculate springs in 2d? I'm working on a physics engine ( a very simple one ). It has points bouncing off triangles, I want to connect the points with springs... Any help appreicated... :)
  9. 2D Bounce Engine

    I'm working on a 2d physics engine now, I have the point bouncing off an edge (you can treat the edge as a ray), Here's the code.. BTW: The Angle class is using radians, so I don't have to convert them back and forth. It automaticly wraps around, I can post the code if you want. //a is the point that will bounce off Angle pointAngle = a.MoveAngle; //The ray that the point will bounce off of Angle lineAngle = new Angle((float)Angle.GetAngle(p1.Y - p2.Y, p1.X - p2.X)); //A line perpendicular (normal) to the lineAngle Angle normalAngle = new Angle(lineAngle.A); //The distance between the point and the normal float gap = normalAngle.A - pointAngle.A; //If the normal is facing the wrong direction if (gap > FMath.PI) { //(remember, all of this is using an Angle class,it wraps around) //Flips the normal normalAngle.A -= FMath.PI; //recaclculate the gap so that it is correct gap = normalAngle.A - pointAngle.A; } //The gap added to the normal is the bouncing off point a.MoveAngle.A = normalAngle.A + gap; This is C# by the way
  10. Line to point response

    nice, hopefully I can make something around that level :D
  11. Line to point response

    Thanks, you made that engine...?
  12. Line to point response

    hmmm, guess I'll convert the angle into a vector... Thanks!
  13. Line to point response

    I'm doing a simple 2d physics engine and I'm trying to get a point to bounce off a line. I already know which line it is hitting, all the angles, ect... Any help appreicated (btw, my angles go ccw).
  14. 2D Line Intersection

    The way I found if the lines intersected was to first convert both of the lines to a mid point between the line's p1 and p2) and an angle (The type of angle is the "m" angle out of y = mx+b). This converts both the lines to rays. I found where the lines intersected with the y = mx+b. To find b I used the code here: double b1 = (p1.Y - p2.Y) + ((p2.X - p1.X)*m1); It is assumes b2 is zero. With the intersection point it's easy, I just put a box around both of the lines and if the point is within both of the rectangles, the lines intersect. I'll post the source code if you need it. -Free
  15. Buying computer

    I'm buying a computer online, and I'm wondering where to buy it... I'm also wondering athlon 64 vs pentium 4 w/ht. I'm aiming around a athlon 3700, 1 gb mem (ddr or ddr2 intel...), 200 gigs, 7800 gt, around 1100 US. Any help appreicated! PS - I'm wondering between cyberpowersystem, ibuypower, or another site. Thanks in advance!