MapObjectPoseToWorldSpace (XSIMath)

Description

Converts a Pose described in a given ObjectSpace to WorldSpace.

Scripting Syntax

XSIMath.MapObjectPoseToWorldSpace( ObjectSpace, Pose )

C# Syntax

SITransformation XSIMath.MapObjectPoseToWorldSpace( SITransformation in_pObjectSpace, SITransformation in_pPose );

Parameters

Parameter

Type

Description

ObjectSpace

SITransformation

ObjectSpace in which the pose is described.

Pose

SITransformation

Pose to convert.

Return Value

SITransformation (pose)

Examples

1. JScript Example

/*
   This example demonstrates how to map a cube's position relative to its parent 
   to global coordinates
*/

NewScene (null, false)
var oRoot = Application.ActiveProject.ActiveScene.Root
var oCubeParent = oRoot.AddGeometry("Cube","MeshSurface", "CubeParent")
oCubeParent.Kinematics.Global.Parameters("posx").value = 2.0
oCubeParent.Kinematics.Global.Parameters("posy").value = 4.0

var oCubeChild =  oCubeParent.AddGeometry("Cube","MeshSurface", "CubeChild" )
oCubeChild.Kinematics.Global.Parameters("posz").value = 3.0
oCubeChild.Kinematics.Global.Parameters("rotx").value = 45.0

var oTransParent = oCubeParent.Kinematics.Global.Transform

// This is the translation relative to the parent cube
var oTrans = oCubeChild.Kinematics.Local.Transform

var oVec3 = XSIMath.CreateVector3()
oTrans.GetTranslation (oVec3)

Application.LogMessage ("The translation of the cube relative to its parent: x " +
               oVec3.x + " y " + oVec3.y + " z " + oVec3.z)

// oTrans is relative to the parent cube, but can be mapped back to
// global space like this:

var oWorldTrans = XSIMath.MapObjectPoseToWorldSpace(oTransParent, oTrans)
oWorldTrans.GetTranslation (oVec3)

Application.LogMessage ("The translation of the cube relative to the origin of the universe: x "
              + oVec3.x + " y " + oVec3.y + " z " + oVec3.z)

// Note: The global KinematicState already expresses this information


var oTransGlobal = oCubeChild.Kinematics.Global.Transform
oTransGlobal.GetTranslation (oVec3)

Application.LogMessage ("The translation of the cube relative to the origin of the universe: x " +
               oVec3.x + " y " + oVec3.y + " z " + oVec3.z)

// Expected output:
//INFO : The translation of the cube relative to its parent: x -2 y -4 z 3
//INFO : The translation of the cube relative to the origin of the universe: x 0 y 0 z 3
//INFO : The translation of the cube relative to the origin of the universe: x 0 y 0 z 3

2. VBScript Example

'
'  This example demonstrates how to map a cube's position relative to its parent 
'  to global coordinates
'

set oRoot = Application.ActiveProject.ActiveScene.Root
set oCubeParent = oRoot.AddGeometry("Cube","MeshSurface", "CubeParent")
oCubeParent.Kinematics.Global.Parameters("posx").value = 2.0
oCubeParent.Kinematics.Global.Parameters("posy").value = 4.0

set oCubeChild =  oCubeParent.AddGeometry("Cube","MeshSurface", "CubeChild" )
oCubeChild.Kinematics.Global.Parameters("posz").value = 3.0
oCubeChild.Kinematics.Global.Parameters("rotx").value = 45.0

set oTransParent = oCubeParent.Kinematics.Global.Transform

' This is the translation relative to the parent cube
set oTrans = oCubeChild.Kinematics.Local.Transform

set oVec3 = XSIMath.CreateVector3
oTrans.GetTranslation oVec3

Application.LogMessage "The translation of the cube relative to its parent: x " &_
               oVec3.x & " y " & oVec3.y & " z " & oVec3.z

' oTrans is relative to the parent cube, but can be mapped back to
' global space like this:

set oWorldTrans = XSIMath.MapObjectPoseToWorldSpace(oTransParent, oTrans)
oWorldTrans.GetTranslation oVec3

Application.LogMessage "The translation of the cube relative to the origin of the universe: x " &_
               oVec3.x & " y " & oVec3.y & " z " & oVec3.z


'
' Note: The global KinematicState already expresses this information
'

set oTransGlobal = oCubeChild.Kinematics.Global.Transform
oTransGlobal.GetTranslation oVec3

Application.LogMessage "The translation of the cube relative to the origin of the universe: x " &_
               oVec3.x & " y " & oVec3.y & " z " & oVec3.z


' Expected output:
'INFO : The translation of the cube relative to its parent: x -2 y -4 z 3
'INFO : The translation of the cube relative to the origin of the universe: x 0 y 0 z 3
'INFO : The translation of the cube relative to the origin of the universe: x 0 y 0 z 3


SOFTIMAGE|XSI v6.01     

Return to Softimage XSI Index