Manual movement and rotating

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Manual movement and rotating

Postby Aldeminor » Sat Jul 24, 2010 2:32 pm

Ok. we have newton body, we can push it by forces and rotate by torques. But how to set body's position manualy in x,y,z and turn it on required angle? Is it NewtonBodyGetMatrix and NewtonBodySetMatrix for movement? How to use it and how to set angle of turn?
Also will be good to know, how to return body's position and angles.

(I know, its a stupid questions about very basic things, but... our programmer realy break his head about this wall of code :lol: )
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Manual movement and rotating

Postby Stucuk » Sat Jul 24, 2010 3:41 pm

Using the NewtonBodySetMatrix for actual movement of an object should cause Errors in your simulation. Its only really meant for placing objects.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Manual movement and rotating

Postby Julio Jerez » Sat Jul 24, 2010 3:56 pm

you can use NewtonBodyGetMatrix and NewtonBodySetMatrix
and use a function to convert a matrix to euler angles.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Manual movement and rotating

Postby Aldeminor » Sat Jul 24, 2010 4:06 pm

If it cause errors, how to preciosly move body in certain coordinates?
And can you post code example with extracting coords and angles from matrix?

Also, NGD supports quaternions?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Manual movement and rotating

Postby Stucuk » Sat Jul 24, 2010 8:39 pm

It should (Unless its different now) cause errors as you could move one object inside an other object, so instead of reacting like one object hit another as you would get with forces, what you should see is one object trying to get out of another object(With Newton if one object is inside another, the object tries to get back outside the object).
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Manual movement and rotating

Postby Julio Jerez » Sat Jul 24, 2010 11:08 pm

you can reard the quaternion by using void NewtonBodyGetRotation(const NewtonBody* body, dFloat* rotation);
but the only way to set a orientation is by using NewtonBodyGetMatrix

if your angles are in the form of Pitch, Yaw, Roll
meaning Pitch is a rotation around x, yaw rotation around y and roll a rotation aroung z you can use these functions

void NewtonGetEulerAngle (const dFloat* matrix, dFloat* eulersAngles);
void NewtonSetEulerAngle (const dFloat* eulersAngles, dFloat* matrix);

if you use a different order for angle, you will need to get some info on matrix and euler angle from Mathworld or some other place in the net.

you can also check the dMatrix class in newton SDK, it comes with plenty functions for converting matrix to angles, quaternion to angles,
get scale, shear and all kind of opertions on transformation matrices.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Manual movement and rotating

Postby kallaspriit » Sun Jul 25, 2010 3:12 am

I think he mean positioning the body in a way that correctly interacts with the world, I guess to IK joint would be the right tool for that.
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Manual movement and rotating

Postby Aldeminor » Sun Jul 25, 2010 4:35 am

Thanks all for reply.
kallaspriit wrote:I guess to IK joint would be the right tool for that.

Can you, please, explain more detail about? What is IK?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Manual movement and rotating

Postby kallaspriit » Sun Jul 25, 2010 7:50 am

CustomKinematicController NGD custom joint has methods like:
Code: Select all
void SetTargetRotation (const dQuaternion& rotation);
void SetTargetPosit (const dVector& posit);
void SetTargetMatrix (const dMatrix& matrix);


This tries to move and orient a body to given position-orientation by applying appropriate forces, but without exceeding some limits so if there's something in the way, it wont just penetrate it but try to push it away.
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron