Converts a position described in an ObjectSpace to a position in a different ObjectSpace.
oReturn = XSIMath.MapObjectPositionToObjectSpace( ObjectSpace, Space, Position ); |
SIVector3 (position)
Parameter | Type | Description |
---|---|---|
ObjectSpace | SITransformation | ObjectSpace in which the position is described. |
Space | SITransformation | Space in which we want to convert the position . |
Position | SIVector3 | Position to convert. |
var oCube = ActiveSceneRoot.AddGeometry("Cube","MeshSurface"); oCube.Kinematics.Global.Parameters("posy").value = 4.0; oCube.Kinematics.Global.Parameters("posx").value = 2.0; var oGrid = ActiveSceneRoot.AddGeometry("Grid", "MeshSurface"); oGrid.Kinematics.Global.Parameters("posy").value = -2.0; if( Above(oCube, oGrid) ) Application.LogMessage ( "The Cube is above the Grid" ); else Application.LogMessage ( "The Cube is not above the Grid" ); //Function that returns true if in_obj1 is above in_obj2. //Which means that all " y" values of in_obj1 vertices relative to in_obj2 are bigger //than in_obj2 "y" values function Above(in_obj1, in_obj2) { var l_trans1, l_trans2, l_pos, l_biggesty; l_biggesty = 0; var oGeometry2 = in_obj2.activeprimitive.geometry; var l_nbPoints = oGeometry2.Points.Count; //Determine the upper position on in_obj2 for(var i = 0; i < l_nbPoints; i++) { if (oGeometry2.Points(i).position.y > l_biggesty) l_biggesty = oGeometry2.Points(i).position.y; } l_trans1 = in_obj1.Kinematics.Global.Transform; l_trans2 = in_obj2.Kinematics.Global.Transform; var oGeometry1 = in_obj1.activeprimitive.geometry; l_nbPoints = oGeometry1.Points.Count; //Determine if all vertices of in_obj1 are above in_obj2 for(var i = 0; i < l_nbPoints; i++) { l_pos = oGeometry1.Points(i).position; l_pos = XSIMath.MapObjectPositionToObjectSpace(l_trans1, l_trans2, l_pos);; if( l_pos.y < l_biggesty ) return false; } return true; } //OUTPUT //INFO : The Cube is above the Grid |
set oRoot = Application.ActiveProject.ActiveScene.Root set oCube = oRoot.AddGeometry("Cube","MeshSurface") oCube.Kinematics.Global.Parameters("posy").value = 4.0 oCube.Kinematics.Global.Parameters("posx").value = 2.0 set oGrid = oRoot.AddGeometry("Grid", "MeshSurface") oGrid.Kinematics.Global.Parameters("posy").value = -2.0 if Above(oCube, oGrid) then Application.LogMessage "The Cube is above the Grid" else Application.LogMessage "The Cube is not above the Grid" end if 'Function that returns true if in_obj1 is above in_obj2. 'Which means that all " y" values of in_obj1 vertices relative to in_obj2 are bigger 'than in_obj2 "y" values Function Above(in_obj1, in_obj2) Dim l_trans1, l_trans2, l_pos, l_biggesty l_biggesty = 0 'Determine the upper position on in_obj2 for each p in in_obj2.activeprimitive.geometry.points if p.position.y > l_biggesty then l_biggesty = p.position.y end if next set l_trans1 = in_obj1.Kinematics.Global.Transform set l_trans2 = in_obj2.Kinematics.Global.Transform 'Determine if all vertices of in_obj1 are above in_obj2 for each p in in_obj1.activeprimitive.geometry.points set l_pos = p.position set l_pos = xsimath.MapObjectPositionToObjectSpace(l_trans1, l_trans2, l_pos) if l_pos.y < l_biggesty then Above = False Exit Function end if next Above = True End Function |