A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by FSA » Thu Sep 27, 2012 1:45 pm
When i set a matrix with NewtonBodySetMatrix (RotationMatrix) I get an error:
dgBody.h Line 738
Expression: dgAbsf(val-1.0f) < 1.0e-5f
What does it mean?
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by JoeJ » Thu Sep 27, 2012 3:25 pm
Either the axis you give are of nonuniform length, or the axis ar not perpendicular to each other.
Mostly this happens because nonuniform scale, see
viewtopic.php?f=9&t=7334&start=15 for too much details about that
-
JoeJ
-
- Posts: 1453
- Joined: Tue Dec 21, 2010 6:18 pm
by FSA » Fri Sep 28, 2012 8:30 am
Oh. You're right...
That's my matrix
-1.#IO -1.#IO -1.#IO 0.000
-1.#IO -1.#IO -1.#IO 0.000
-1.#IO -1.#IO -1.#IO 0.000
0.000 0.000 0.000 1.000
I will chek where the error occurs...
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by FSA » Fri Sep 28, 2012 9:42 am
Ok. My code to calculate the RotationMatrix:
- Code: Select all
Vector3 m_vYAxis, m_vZAxis, m_vXAxis;
m_vYAxis = Vector3(0.0f,1.0f,0.0f);
m_vZAxis = Vector3(0.0f, 0.0f, 1.0f);
m_vXAxis = Vector3(1.0f, 0.0f, 0.0f);
// Rotation um die x-Achse
Matrix mRotation( MatrixRotationX( rot.x ) );
m_vYAxis = Vector3TransformNormal( m_vYAxis, mRotation );
m_vZAxis = Vector3Cross( m_vXAxis, m_vYAxis );
// Rotation um die y-Achse
mRotation = MatrixRotationY( rot.y );
m_vXAxis = Vector3TransformNormal( m_vXAxis, mRotation );
m_vZAxis = Vector3Cross( m_vXAxis, m_vYAxis );
// Rotation um die z-Achse
mRotation = MatrixRotationZ( rot.z );
m_vXAxis = Vector3TransformNormal( m_vXAxis, mRotation );
m_vYAxis = Vector3TransformNormal( m_vYAxis, mRotation );
return MatrixAxes( Vector3Normalize(m_vXAxis), Vector3Normalize(m_vYAxis), Vector3Normalize(m_vZAxis) );
Vector3TransformNormal:
- Code: Select all
FF_API Vector3 Vector3TransformNormal( const Vector3& v,
const Matrix& m )
{
const float fLength = Vector3Length( v );
if( fLength == 0.0f ) return v;
const Matrix mTransform( MatrixTranspose( MatrixInvert( m ) ) );
return Vector3Normalize( Vector3( v.x * mTransform.m11 + v.y * mTransform.m21 + v.z * mTransform.m31,
v.x * mTransform.m12 + v.y * mTransform.m22 + v.z * mTransform.m32,
v.x * mTransform.m13 + v.y * mTransform.m23 + v.z * mTransform.m33 ) )
* fLength;
}
MatrixRotationX/Y/Z create a Rotation Matrix. Vectro3Cross is the crossproduct.
Newton Crash when I change the Z Rotation.
Matrix:
0.997 0.000 0.075 0.000
0.000 0.989 0.149 0.000
-0.074 -0.149 0.986 0.000
0.000 0.000 0.000 1.000
Tanks
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by JoeJ » Sat Sep 29, 2012 6:59 am
So what you want is to build a MAtrix from Euler Angles?
I assume your code produces a right handed instead of a left handed coordinate system (or vice versa) - or theres another error in it.
At least it's clear that it's very inefficient.
Try to replace it with code from here:
viewtopic.php?f=9&t=7237&p=49723&hilit=euler+angles#p49723The order seems to be 0x012 for your case.
If you work with public engine (irrlicht ?), can you tell which one and what order is right?
At lot of people have trouble with that issue.
-
JoeJ
-
- Posts: 1453
- Joined: Tue Dec 21, 2010 6:18 pm
by FSA » Sun Nov 11, 2012 2:01 pm
I have let this problem be a problem
I have a new problem(with core 300).
In the picture you can see it. It happens when i pick a body and turn around with the body. To pick a body I add force and torque to the body. What is the problem? It hasn't happened with core 200.
- Attachments
-
- Error.png (13.72 KiB) Viewed 32781 times
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Sun Nov 11, 2012 2:08 pm
that a really bad bug that should never ever happens. what are you doing to get that?
It means a body was at rest but somehow after it was deemed to be resting somehow places in the simulation.
I have never seem it happens?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Sun Nov 11, 2012 2:32 pm
Next picture.
Here is my code:
- Code: Select all
/*Callback*/
void BodyCallback (const NewtonBody* body, dFloat timestep, int threadIndex)
{
NewtonBodyAddForce (body, g_vLinear);
NewtonBodyAddTorque(body, g_vTorque);
}
I calculate force an torque with formula from JoeJ. I think it is the right calculation because with core 200 it worked.
- Attachments
-
- Error3.PNG (15.99 KiB) Viewed 32777 times
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Sun Nov 11, 2012 2:52 pm
No any of those error should be happening, something is very wrong. I you get an lru pout of sync then not else will work.
island row coun will fal because it will add more bodies than were not support to be consired. I cannot imagine how that happened, It is not possible unless you run the engine straight for over 200 years
when you say "I pick a body and walk with it" from where are you doing that? what ever it is is not right.
an not the friction in the get is 0.6 like is has always being the defualt in all version of the engine. I do not know what could that be.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Sun Nov 11, 2012 3:00 pm
I give you my code to calculate the force I add with NewtonBodyAddForce.
- Code: Select all
if(m_pBody)
{
if(m_bFirstFrame)
{
m_bFirstFrame = false;
m_mOffsetMatrix = MatrixIdentity();
NewtonBodyGetMatrix(m_pBody, m_mOffsetMatrix);
m_fCameraOffsetX = CamHandler->GetCameraAngleX();
}
// Body modification
NewtonBodySetForceAndTorqueCallback(m_pBody, BodyCallback);
NewtonBodySetContinuousCollisionMode(m_pBody, 1);
//******************************
// Translation
Vector3 vVelocity;
Vector3 vBodyPosition;
Vector3 vCameraDir;
Vector3 vCameraPos;
Matrix mMatrix;
float fMass, fA, fB, fC;
NewtonBodyGetVelocity (m_pBody, vVelocity);
NewtonBodyGetMatrix (m_pBody, mMatrix);
NewtonBodyGetMassMatrix (m_pBody, &fMass, &fA, &fB, &fC);
vBodyPosition = MatrixGetPosition(mMatrix);
vCameraDir = CamHandler->GetCameraDir();
vCameraPos = CamHandler->GetCameraPos();
vCameraPos += vCameraDir * 25.0f;
m_vLinear = ( (vCameraPos - vBodyPosition) * 20.0f - vVelocity ) * (fMass / fTime);
m_vLinear is the force i apply.(NewtonBodyAddForce (body, m_vLinear);
With "I move with it" I mean, when I walk the body is always on the same distance(see code).
Thank you for reading this and be so patient
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Sun Nov 11, 2012 3:05 pm
maybe set continue collsion have a bug, try not using that see if it work.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Sun Nov 11, 2012 3:24 pm
Yes that solved the problem! The problem with the high friction is also solved! So continues collision mode has a bug?
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
by Julio Jerez » Sun Nov 11, 2012 3:26 pm
Ha, so there must be a bug in CCD that is changes the LRU sincronization between the Collision system and the dynamics system.
can you send me a demo that I can try, one that I can turn CCD on and off?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by FSA » Sun Nov 11, 2012 3:46 pm
Yes give me a moment...
-
FSA
-
- Posts: 318
- Joined: Wed Dec 21, 2011 9:47 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 51 guests