EgtExecutor 2.6d4 :
- aggiunta di alcune funzioni lua per i Quaternion.
This commit is contained in:
Binary file not shown.
@@ -530,6 +530,83 @@ LuaBBoxLocToLoc( lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaQuaternionFromAxisAngle( lua_State* L)
|
||||
{
|
||||
// 2 parametri : vtAx, dAngDeg
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 1, vtAx)
|
||||
double dAngDeg ;
|
||||
LuaCheckParam( L, 2, dAngDeg)
|
||||
LuaClearStack( L) ;
|
||||
// calcolo il quaternione che produce la rotazione equivalente
|
||||
Quaternion qtQ = FromAxisAngle( vtAx, dAngDeg) ;
|
||||
if ( ! qtQ.IsSmall())
|
||||
LuaSetParam( L, qtQ) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaQuaternionToAxisAngle( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Quaternion
|
||||
Quaternion qtQ ;
|
||||
LuaCheckParam( L, 1, qtQ)
|
||||
LuaClearStack( L) ;
|
||||
// calcolo l'asse e l'angolo di rotazione equivalenti
|
||||
Vector3d vtAx ;
|
||||
double dAngDeg ;
|
||||
bool bOk = ToAxisAngle( qtQ, vtAx, dAngDeg) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, vtAx) ;
|
||||
LuaSetParam( L, dAngDeg) ;
|
||||
return 2 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaQuaternionFromFrame( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Frame
|
||||
Frame3d frFrame ;
|
||||
LuaCheckParam( L, 1, frFrame)
|
||||
LuaClearStack( L) ;
|
||||
// calcolo il quaternione che produce l'orientamento di questo frame tramite rotazione dal globale
|
||||
Quaternion qtQ = FromFrame( frFrame) ;
|
||||
if ( ! qtQ.IsSmall())
|
||||
LuaSetParam( L, qtQ) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaQuaternionToFrame( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Quaternion
|
||||
Quaternion qtQ ;
|
||||
LuaCheckParam( L, 1, qtQ)
|
||||
LuaClearStack( L) ;
|
||||
// calcolo il frame equivalente come orientamento a quello globale ruotato dal quaternione
|
||||
Frame3d frFrame ;
|
||||
bool bOk = ToFrame( qtQ, frFrame) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, frFrame) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeoBase( LuaMgr& luaMgr)
|
||||
@@ -557,5 +634,9 @@ LuaInstallGeoBase( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBBoxToGlob", LuaBBoxToGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBBoxToLoc", LuaBBoxToLoc) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtBBoxLocToLoc", LuaBBoxLocToLoc) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtQuaternionFromAxisAngle", LuaQuaternionFromAxisAngle) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtQuaternionToAxisAngle", LuaQuaternionToAxisAngle) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtQuaternionFromFrame", LuaQuaternionFromFrame) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtQuaternionToFrame", LuaQuaternionToFrame) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user