## Set angle

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

### Set angle

Hi everybody!

I would like to know if there is a way to set the angle of a NewtonBody?

Example:

I have a NewtonBody (player) and I would like to turn it of 45 degrees.

I tried with SetTorque but it did not worked as expected...

thank,
funbidoux

Posts: 3
Joined: Tue Nov 11, 2008 7:37 pm

### Re: Set angle

If you use the Custom joint UpVector it's simple.

Just to call on the desired direction.
// bu animating the orientation of the pin vector the application can change the orientation of the picked object
void CustomUpVector::SetPinDir (const dVector& pin)
{
m_localMatrix1 = dgGrammSchmidt(pin);
}
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 725
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Set angle

Thank for your reply but I'm not sure if I understand... pin is my angle (0,45,0)? and what is dgGrammSchmidt? is it part of newton?
funbidoux

Posts: 3
Joined: Tue Nov 11, 2008 7:37 pm

### Re: Set angle

It's a math utility, but yes you can find the command in newton file utils.
And maybe if you have some math utils in coming with your 3d system this can have it already.

Yes you can change the joint pin angle with this command I don't remember the format if it is in degre or in angle.
Maybe you need to use value*180/PI but I really don't remember sorry.
It make a long time that I have test it.

Remember you this work only if you use the custom joint UpVector.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 725
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Set angle

You can manipulate and set the newton object matrix directly to rotate objects instantly to any dersired rotation and / or location.
Help improving the Newton Game Dynamics WIKI

JernejL

Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

### Re: Set angle

I tried what you told me but it is not working...
Code: Select all
`float matrix[4][4];NewtonBodyGetMatrix(model.m_body,&matrix[0][0]);matrix4 mat;memcpy(mat.M, matrix, sizeof(float)*16);mat.setRotationDegrees(mat.getRotationDegrees()+core::vector3df(0,15,0));NewtonBodySetMatrix(model.m_body,&mat.M[0]);`

Is there a way to get an exemple or a tutorial?

thank,
funbidoux

Posts: 3
Joined: Tue Nov 11, 2008 7:37 pm