# peibol

Members

12

354 Neutral

• Rank
Member
1. ## calculate the determinant

It was the origin term what mislead me. Everything is clear now. Thanks for the explanation.
2. ## calculate the determinant

Just one clarfication to Alvaro's otherwise fine answer: both for 2x2 matrix and 3x3 matrix determinants equal to 0, it doesn't necessarily mean the actual lines or planes contain the origin. However, as vectors alone don't have information about their placement, you can think of your vectors as being placed in the origin if you like, for these calculations at least. Or maybe I misunderstood the notes between parentheses.
3. ## newbie problem with pygame, moving rectangle

Don't know anything about pygame but after looking the internet I think in the for event in pygame.event.get() loop you should do if event.key == pygame.K_LEFT instead of if pygame.event == pygame.K_LEFT and the same for the other key (K_RIGHT).
4. ## Help with visibility test for AI in 2D

I have no experience with 3D collision but I think you don't need it for this simple scheme. I liked the overall concept very much. Let's assume AI height h1, height of layer h, player height h2 and distance from AI to border d1, then the player will be visible when its distance from border is d2 or greater, with: d2 = d1*(h-h2)/h1 This is basic trigonometry from the following diagram: [sharedmedia=gallery:images:4266] You can use any units with this formula, tiles, for example: h1 = 1 h2 = 1 (player is as tall as the AI) h = 3 (layer height is 3 times AI and player height) d1 = 2 (AI 2 tiles away from border) Player is visible if his distance from border equals or is greater than: 2*(3-1)/1 = 4. So player visible if it is 4 or more tiles away from border.
5. ## AI visibility concept

From the album for posts

6. ## Including friction in a collision response

Quote:Original post by BattleMetalChris By the calculations you've given, in both spinning cases the stationary sphere ends up with exactly the same new angular velocity after the collision. However, in the case where the angular velocity is zero, it has zero angular velocity after the collision. This is clearly nonsense. You are completely right here. I thought the equations behave differently, but now I see it. I should have checked more carefully before. Sorry.
7. ## Including friction in a collision response

[quote]Original post by BattleMetalChris Quote:Original post by peibolMoreover, none of the solids in the collision is free to move linearly as a result from the collision, the momentum is not conserved Quote: They are free to move linearly, and momentum is conserved, it's just that the earth is so big compared to the car that you don't notice it move. They are not free to move linearly in relation to each other: the brake is hold in position by the rest of the car, and the wheel is held in position by the axis. I didn't think you would include the friction of the wheel with the earth. Are they also colliding? I think there is a misunderstanding between collisions and contact forces. I'm pretty new to physics engines so maybe anything in contact is treated as a collision and I'm completely wrong. I really don't know.
8. ## Including friction in a collision response

Yes, the car argument is valid if you consider that one of the solids in the collision can be externally forced to stay in place (speed 0), and that the collision can last for a few seconds, if needed. But thats not how collisions work. Moreover, none of the solids in the collision is free to move linearly as a result from the collision, the momentum is not conserved, all the kinetic energy is lost in form of heat/deformation so you don't need collisions at all to modelate it. I'm not sure what is what you are trying to model: something like the spheres colliding or something like the wheel and brake? I hope the videos will be revealing :oD Going back to collisions, the contact points dont't need to reach the same speeds at all: the friction force disapears because the solids are no longer in contact, not because the points in contact have the same speed. Again, if you are forcing the solids to remain in contact, it is not a collision. It is something else. As a result from the collision, the solids can have gained/lost angular momentum. If the solids had no lineal speed before collision (so it is very unlikely they could collide :oD) then both of them could not reverse their spins, but one of them could. If any of them had linear speed, then both of them could reverse their spins as a result from the collision. It seems our points of view have collided :oD [Edited by - peibol on September 1, 2010 5:20:25 PM]
9. ## Including friction in a collision response

It was part my fault for not understanding. The word tangential is the one to use, like in "tangential component". It was the "tangent to the normal" what made me think you had the component in the wrong direction, sorry. I still think that there is nothing wrong with the colliding objects having their relative spins completely reversed as a result of a collision: imagine 2 non-rotating spheres. One of them stationary, for simplicity's sake. The trajectory of the other doesn't pass through the center of the first ball. When they collide, if friction forces are taken into account, they will both adquire angular speed. If the spheres started with a small angular speed, they could end with their spin reversed after the collision. There is no problem at all with that with current physic laws. And I'm affraid they are here to stay for long :D. The example of the wheel and brake is not valid because it is not a collision. It is just the result of the friction force between two solids in contact. It always oposes relative movement between the solids, so if they somehow inverted their relative movements, the friction force would also be reversed. If no external forces are trying to slide one solid against the other, they will stop sliding instead of changing their direction. Anyway, it is your model, so if you have found a model that behaves the way you like and satisfies you, it is up to you to keep with it. It would be great to see these videos.
10. ## Including friction in a collision response

Hello, I have read the paper and the procedure described there seems complicated to me. Before trying this, maybe you should try a simpler aproach: You can greatly simplify things considering the collision to be instantaneous and forgetting all the dynamic friction thing. You can find the ecuations here. The reply of the post only says that there is no need to include friction forces in the calculation of the impulse. The ecuations in the post are for rigid solids, but can be simplified if you only want to use particles. Bourg is right, so just another pair of things, to make sure you understood the tangent component of the impulse due to friction: -The component is not tangent to the normal, but tangent to the normal surface, so it is perpendicular to the normal. As the post says, it is calculated as follows: -The tangent normal is calculated with this equation. t = [(n x Vr) x n] tangent_normal = t/|t| All the variables in the ecuations are vectors, and x is the vectorial product (or cross product). With this, I think the odd behavior you saw should dissapear. I hope this helps.
11. ## Conservation of Momentum vs COR(on collision result)

Hello, the calculations in the book are right, but made in a strange way, because it happens to be very easy to implement them this way. For example, the author uses the inverse mass version of the formulas instead of just using the mass, because the ecuations are simpler at the cost of being less intuitive. One of the tricky parts is calculating the totalInvertedMass. Example: mA = 5, mB = 1 intuitively, you could be tempted to calculate the totalInvertedMass as 1/(1+5) = 1/6, but this is wrong. In fact, the calculation is done as follows: totalInvertedMass = 1/5 + 1/1 = 6/5 (that is, the sum of the inverted masses of the particles) You are right saying that momentum is conserved, so impulse is 0. But this is only true when applied to the whole system: different particles can change their velocities without changing their masses and the total momentum still remain the same. Example: A( m = 5, v = 1 ) B( m = 1, v = -5 ) COR = 1.0: initial momentum = mA*vA + mB*vB = 0 vA_after = -1 m/s vB_after = 5 m/s KE_after = 15 J (sorry helloworld992, but kinetik energy is 1/2*m*v^2, not m*v^2 :D) So final momentum = 5*(-1)+1*5 = 0 and the total impulse is final momentum - initial momentum = 0. In this example, both initial momentum and final momentum are 0 but it is just coincident, not a requisite. They could be any value (but both the same), and the total momentum would still be conserved. What the book calculates as impulse is really the impulse per inverted mass ( the inverted mass weird thing again) applied to each of the particles. Strictly talking, each particle gets the same impulse applied, but in oppossite directions (this is done when multiplying by the contact normal and the -contact normal). Your calculations were right untill the impulse calculation. From there on: impulse (per inverted mass, remember) = deltaV/totalInvertedMass. deltaV = separatingVelocity-finalSeparatingVelocity = -6-6 = -12 totalInvertedMass = particleAinvertedMass + particleBinvertedMass = 1/5 + 1 = 6/5 so impulse = -12/(6/5) = -10 vA_after = vA_before + impulse*particleAInvertedMass*contactNormal = 1-10*(1/5)*1 = 1-2= -1 vB_after = vB_before + impulse*particleBInvertedMass*(-contactNormal) = -5-10*(1/1)*(-1)= -5+10 = 5 If you still want to calculate the velocities using the impulse and forget all the inverted mass and separating velocities thing, you must solve the following system of equations: COR = -(vB_after-vA_after)/(vB_before-vA_before) (this is COR's definition) mA*vA_before + mB*vB_before = mA*vA_after + mB*vB_after (momentum conservation) this is 2 ecuations with 2 unknowns (vA_after and vB_after) so it is solvable and has unique solution. From these ecuations you would get the solutions for vA_after and vB_after. Surely you can solve yourself or find the solutions in the web, if you insist in doing the calculations on your way. Hope this helps.
12. ## [sdl] code like "if do something, press key X"?

Hello, I understand you want the SDL application to make another application "think" some other key has been pressed when certain condition has been met and the user presses a certain key. In Linux. It seems the solution depends on the windows (not Windows :oD ) system used. Maybe this thread can help you. Good luck!
13. ## SDL GUI optimizations Curious questions..

Hello, I'm new to the Forums. Hope the following helps... First thing I think is you should limit your for cycles to the minimum of iterations. It seems each for goes from i=0 to MAX_SCENE_COMPONENTS. If MAX_SCENE_COMPONENTS is a big number.... your cycle goes slow even if you have a little number of components. Maybe you should have a variable with the actual number of components at any time and do the for cycles for the number of actual components. Be aware that this would only work if the actual components at any time ocuppy the lowest possitions in the array Components[]. You can not just "load" all the components in the array and have, for example, only Components[4] and Components[7] "active". You can try if this helps improve performance, just changing the value of MAX_SCENE_COMPONENTS to 1 or 2, the number of components in your example.