Force and velocity equation

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Force and velocity equation

Postby Leadwerks » Tue Jan 20, 2009 9:32 pm

If I have a body with a mass of 10, and I want it to move 3 units per second, what force do I add to make this happen, and what is the velocity I would set?

Is this correct?:

NewtonBodySetVelocity(body,[3.0,0.0,0.0])
NewtonBodyAddTorque(body,[30.0,0.0,0.0])
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Force and velocity equation

Postby agi_shi » Tue Jan 20, 2009 9:51 pm

Looks correct to me.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: Force and velocity equation

Postby Leadwerks » Wed Jan 21, 2009 2:16 am

I am having a lot of trouble picking up an object and making it go to the correct place in front of the player.

force = ( ( desiredposition - currentposition ) - currentvelocity ) * mass

When I use this formula, the object acts very "springy" and takes a long time to come to rest when I move or rotate the player.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Force and velocity equation

Postby Julio Jerez » Wed Jan 21, 2009 4:14 am

leadwerk the best way to do that is by making a joint, to calculate the forces for you.
The joint woirl well wi teh collion, and you can move at will.
Agi does that way.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Force and velocity equation

Postby Leadwerks » Wed Jan 21, 2009 6:36 pm

The fixed joint example is completely inaccessible to me because it uses all the library C++ code.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Force and velocity equation

Postby Yezide » Wed Jan 21, 2009 6:38 pm

The way I do this (holding object infront of player, ala hl2) is to use a combination of PID controllers and springs.
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Force and velocity equation

Postby Julio Jerez » Wed Jan 21, 2009 8:21 pm

Ok how about me replacing the pick code in the SDK with a pick like in just like you are saying.
and I add the C export.
this is teh inetface I can thong of.

Code: Select all
bool MovementCallback(Matrix&* target, float MaxStrength, *userData)
{
   mouseInfo = (MouseInfo*) userData

  if (mopsuestildown) {
   // het you place the destination matrix and the streng of the joint
      // copy teh destnation an dteh strent into target, max strendg
     return 1
   } else {
      //to signal the joint wil be destroyed.
      return 0    ;
  }
   ....
}


// c inteface
Joint CreatePickJoint (body, MovementCallback, void* userData)


basicall you using like this

you shot a ray and find what object you want to pick
Code: Select all
if (Mouseclick) {
       Body = RacjPickBody()
       if (body) {
            CreateJoint (Body, movement, * mouseInfo);
     }
}

is thsi what you are lokking for?


The reason the joint is the best way to go is that, i calcul et eteh exat force to make teh motion, but if teh body collide with somethomng the the collision generate force that will pass teh force limits.
alst teh rotation are alway exact, object placement liek buidl compelx strution is a give.
I do no really see any dow side. and quiet frnkle I do no kwno why no oen has done before.
you can actually make this king of object to behave as smooth as a feather, and very strong if you want.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Force and velocity equation

Postby Leadwerks » Wed Jan 21, 2009 9:37 pm

A fixed joint, or something like you describe, would be useful.

I know I am whining a lot today, it is because I am returning to physics and there is a lot of stuff that can be improved in my code.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Force and velocity equation

Postby agi_shi » Wed Jan 21, 2009 9:41 pm

Wow, yeah, something like that would be awesome :D
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: Force and velocity equation

Postby Julio Jerez » Thu Jan 22, 2009 2:10 pm

Ok Master Agi, Leadwerk the joint is in.
You can download the window SDK an try.
It is still very basic but you can see how it works.

I has two more of operations, fir is the same as the pick object function, and the second is pick object plus fix orientation.
All parameter can be change at will.
At the moment is soft but this can be adjusted by controlling the friction.

The good thing about using the joint is that it is very easy to make a smart pick functions.

For example you wan that the body react fast when you move fast, and gentle when is placed on top of oteh objects.

The can be done in many ways by setting the linear and angular friction base on heuristic.

For example we can add a ForeachBody n AABB find if the bodies is close to some obstacle and is so then we low the friction so that has gentle touch, If not body are close then we can make the friction value stronger and the joint is very responsive.
Another way is implementing the PID to adjust in smarter way the friction dynamically.
Another way is the we can use pick but a handle and use a high angular friction that will allow to align the body by using the collision with environment.
These are just few mode I can think of and the will be very time consuming to adjust using springs.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Force and velocity equation

Postby Leadwerks » Thu Jan 22, 2009 10:58 pm

I will give this a try next week. I have got to get that car set up now for TheoLogic and co.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 9 guests