RFShell.GetLocalToGlobalMatrix



Your Ad Here

Description

Retrieves the transformation matrix used to transform point coordinates represented in the local coordinate system of the shell to point coordinates represented in the global coordinates system.

Syntax

Function RFShell.GetLocalToGlobalMatrix(pTMat As RFTMatrix) As RFErrorCode

The GetLocalToGlobalMatrix syntax has these parts:

Part Description
pTMat [OUTRFTMatrix Required. Local to global coordinate system transformation matrix.

Remarks

Sample

Dim rfErr As RFErrorCode
Dim mdObj As RapidForm.RFModel
Dim shObj As RapidForm.RFShell
Dim vtObj As RapidForm.RFVertex

    Set mdObj = RapidForm.Model
    Set shObj = RapidForm.Shell
    Set vtObj = RapidForm.Vertex
    
    Dim shID As RFEntityID
    
    ' Add a blank sell.
    shID = mdObj.AddShell(RF_MEASURED_SHELL, "Simple shell")
    
    ' Register the shell in the GUI database.
    rfErr = RapidForm.UserInterface.AddShellToProjectTree(shID)
    
    rfErr = shObj.SetID(shID)
            
    ' Define the local coordinate of the shell as follows,
    ' The origin = {0,0,10}
    ' U axis = {0,1,0}
    ' V axis = {1,0,0}
    rfErr = shObj.SetMeasuringCoordinate(0, 0, 10, 0, 1, 0, 1, 0, 0)
    
    ' Retreives the local to global transformation matrix.
    Dim l2gMat As RFTMatrix
    rfErr = shObj.GetLocalToGlobalMatrix(l2gMat)
    
    ' Retreives the global to local transformation matrix.
    Dim g2lMat As RFTMatrix
    rfErr = shObj.GetLocalToGlobalMatrix(g2lMat)
    
    ' Add {5,10,-5} point of the local coordinate system as a new vertex in the shell.
    ' All vertex coordinates passed in the AddVertex method are interpreted in reference to the global coordinate.
    Dim orgPt As RFPoint3
    Dim vtID As RFEntityID
    
    orgPt.x = 5
    orgPt.y = 10
    orgPt.z = -5
    
    ' Get the global coordinates of orgPt
    Dim globalPt As RFPoint3
    globalPt.x = l2gMat.m(0, 0) * orgPt.x + l2gMat.m(1, 0) * orgPt.y + l2gMat.m(2, 0) * orgPt.z + l2gMat.m(3, 0)
    globalPt.y = l2gMat.m(0, 1) * orgPt.x + l2gMat.m(1, 1) * orgPt.y + l2gMat.m(2, 1) * orgPt.z + l2gMat.m(3, 1)
    globalPt.z = l2gMat.m(0, 2) * orgPt.x + l2gMat.m(1, 2) * orgPt.y + l2gMat.m(2, 2) * orgPt.z + l2gMat.m(3, 2)
    
    rfErr = shObj.AddVertex(globalPt.x, globalPt.y, globalPt.z, vtID)

    rfErr = vtObj.SetID(vtID)
    
    ' Retrieves the first vertex coordinates in the local coordinate system.
    Dim localPt As RFPoint3
    rfErr = shObj.SetCoordinateMode(RF_LOCAL_COORDINATE_MODE)
    rfErr = vtObj.GetPoint(localPt)
    
    ' Retrieves the first vertex coordinates in the global coordinate system.
    rfErr = shObj.SetCoordinateMode(RF_GLOBAL_COORDINATE_MODE)
    rfErr = vtObj.GetPoint(globalPt)
    
    ' Update the GUI database and redraw the scene.
    rfErr = RapidForm.Document.RegenShell(shID)
    RapidForm.Document.RedrawScene

Return to Rapidform Index


Your Ad Here