Bcc.GetRotationMatrixAlongAxis({vOrigin}, {vDirection}, AngleDegrees)

Description

Provides the 4x4 rotation matrix when rotating around an arbitrary vector a certain number of degrees

Parameters


  • vOrigin – table defining the x,y,z position of the start of the rotation axis vector:  vOrigin={x,y,z}
  • vDirection – table defining the vector direction: vDirection={xDir,yDir,zDir}
  • AngleDegrees – double value representing the number of degrees to rotate

Return

Returns a 4x4 matrix containing the rotations specified in degrees.


The format of the return is the following assuming you have returned to a variable named matrix:


matrix[1] = {1,0,0,0}

matrix[2] = {0,1,0,0}

matrix[3] = {0,0,1,0}

matrix[4] = {0,0,0,1}

Examples


The following example shows the result of calculating a rotation which is 45 degrees around X


-- Get the matrix for rotating 45 degrees around X

matrix = Bcc.GetRotationMatrixAlongAxis({0,0,0}, {1,0,0}, 45)

               

-- Value to build the string for display

temp = ""


-- Iterate through the table to display the values

for k,v in ipairs(matrix) do

       if type(v) == "table" then

               -- Iterate through the sub table containing the values

               for kk, vv in ipairs(v) do

                       temp = temp..vv..", "

               end

       else

       temp = temp..v..", "

       end

       temp = temp.."\n"

end


-- Display a message box of the resulting matrix                 

Bcc.ShowMessageBox(temp)