Crase
02-10-2011, 10:44 PM
Hi everyone !
I am trying something these days and i met some troubles regarding some vectors calcul !
There is what i am trying to do :
I have a null control ( ctrl ) , an other null ( ref-null ) and an other null again ( ik-arm )
I want to calculate a vector between my ref-null and my ik-arm, then i will calculate an angle between my ref vector and the vector i just calculated
There is a picture to explain better :
http://img694.imageshack.us/img694/5583/issueb.jpg (http://img694.imageshack.us/i/issueb.jpg/)
1 : This is the vector that i calculate in my script with
var refvector = ref.Value.Transform.Translation;
2 : This is the vector that i calculate in my script with
var ikvector = ik.Value.Transform.Translation;
3 : This is the vector that i calculate with the vector 1 and 2 :
var vecteurResult = XSIMath.CreateVector3(); // on créé d'abord un vecteur vide
vecteurResult.sub(ikvector,refvector);
4 : This is the angle that i WANT to calculate with :
var theta = vecteurResult.Angle( refvector )
But my theta returns me this angle :
http://img25.imageshack.us/img25/4195/angleft.jpg (http://img25.imageshack.us/i/angleft.jpg/)
and i don't understand why :(
There is a picture of my scripted operator ( which is on my ctrl null )
http://img19.imageshack.us/img19/1743/scripted.jpg (http://img19.imageshack.us/i/scripted.jpg/)
There is the code :
// Calcul of my 2 vectors
var ikvector = ik.Value.Transform.Translation;
var refvector = ref.Value.Transform.Translation;
PrintVector( "ikvector:", ikvector );
PrintVector( "refvector:", refvector );
// Calcul of my third vector
var vecteurResult = XSIMath.CreateVector3(); // on créé d'abord un vecteur vide
vecteurResult.sub(ikvector,refvector);
PrintVector( "vecteur Result:", vecteurResult );
// Angle theta calcul
var theta = vecteurResult.Angle( refvector )
Application.LogMessage( "Angle is " + theta + " radians (" + theta / XSIMath.Pi + " pi)" ) ;
Application.LogMessage( "Angle is " + XSIMath.RadiansToDegrees( ikvector.Angle( refvector ) ) + " degrees" ) ;
function PrintVector( in_Prefix, in_oVec )
{
Application.LogMessage( in_Prefix + " " +
XSIRound(in_oVec.x,3) + ", " +
XSIRound(in_oVec.y,3) + ", " +
XSIRound(in_oVec.z,3) ) ;
}
Out.Value = 0.000000;
I used as input : ref-null.kine.global and ik-arm.kine.global
I'm pretty sure i am doing something wrong somewhere, so if anyone has an idea... :)
I have another problem, I don't know how i can calculate the vector which is on my Y axis on this null :
http://img196.imageshack.us/img196/7956/33430775.jpg (http://img196.imageshack.us/i/33430775.jpg/)
Thanks :)
I am trying something these days and i met some troubles regarding some vectors calcul !
There is what i am trying to do :
I have a null control ( ctrl ) , an other null ( ref-null ) and an other null again ( ik-arm )
I want to calculate a vector between my ref-null and my ik-arm, then i will calculate an angle between my ref vector and the vector i just calculated
There is a picture to explain better :
http://img694.imageshack.us/img694/5583/issueb.jpg (http://img694.imageshack.us/i/issueb.jpg/)
1 : This is the vector that i calculate in my script with
var refvector = ref.Value.Transform.Translation;
2 : This is the vector that i calculate in my script with
var ikvector = ik.Value.Transform.Translation;
3 : This is the vector that i calculate with the vector 1 and 2 :
var vecteurResult = XSIMath.CreateVector3(); // on créé d'abord un vecteur vide
vecteurResult.sub(ikvector,refvector);
4 : This is the angle that i WANT to calculate with :
var theta = vecteurResult.Angle( refvector )
But my theta returns me this angle :
http://img25.imageshack.us/img25/4195/angleft.jpg (http://img25.imageshack.us/i/angleft.jpg/)
and i don't understand why :(
There is a picture of my scripted operator ( which is on my ctrl null )
http://img19.imageshack.us/img19/1743/scripted.jpg (http://img19.imageshack.us/i/scripted.jpg/)
There is the code :
// Calcul of my 2 vectors
var ikvector = ik.Value.Transform.Translation;
var refvector = ref.Value.Transform.Translation;
PrintVector( "ikvector:", ikvector );
PrintVector( "refvector:", refvector );
// Calcul of my third vector
var vecteurResult = XSIMath.CreateVector3(); // on créé d'abord un vecteur vide
vecteurResult.sub(ikvector,refvector);
PrintVector( "vecteur Result:", vecteurResult );
// Angle theta calcul
var theta = vecteurResult.Angle( refvector )
Application.LogMessage( "Angle is " + theta + " radians (" + theta / XSIMath.Pi + " pi)" ) ;
Application.LogMessage( "Angle is " + XSIMath.RadiansToDegrees( ikvector.Angle( refvector ) ) + " degrees" ) ;
function PrintVector( in_Prefix, in_oVec )
{
Application.LogMessage( in_Prefix + " " +
XSIRound(in_oVec.x,3) + ", " +
XSIRound(in_oVec.y,3) + ", " +
XSIRound(in_oVec.z,3) ) ;
}
Out.Value = 0.000000;
I used as input : ref-null.kine.global and ik-arm.kine.global
I'm pretty sure i am doing something wrong somewhere, so if anyone has an idea... :)
I have another problem, I don't know how i can calculate the vector which is on my Y axis on this null :
http://img196.imageshack.us/img196/7956/33430775.jpg (http://img196.imageshack.us/i/33430775.jpg/)
Thanks :)
