// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // // // // Creation Date: June 30 1998 // // // // // // float[] pointMatrixMult ( float $point[], float $matrix[] ) // // // This script returns the multiplication of a point and a // matrix as an array of 3 doubles: //
//      vector * matrix = result
//
//

// Note: The matrix is assumed to be a single dimension // array of 16 elements. //
// Remember: That the arrays are 0-based. // e.g. [1][0] is matrix[4] element // // // float $point[] Co-ordinates of the point. // float $matrix[] The matrix to be used. // // // float[] : Result as an array of 3 doubles. // // // float $p[] = {1,2,3}; // float $m[] = {1,0,0,0,0,2,0,0,0,0,3,0,0,0,0,0}; // pointMatrixMult($p, $m); // // Results: 1 4 9 // // // // global proc float[] pointMatrixMult( float $point[], float $matrix[] ) // // Description: // Multiplies a point by a matrix and returns the result. // { float $result[]; $result[0] = 0.0; $result[1] = 0.0; $result[2] = 0.0; if ( size($point) != 3 || size($matrix) != 16 ) { warning (uiRes("m_pointMatrixMult.kPointArray")); return $result; } // create the node that will do the actual computation // string $multNode; if ( catch($multNode = `createNode pointMatrixMult`) ) { warning (uiRes("m_pointMatrixMult.kCouldNotCreateNode")); return $result; } // set the matrix and point inputs to the node // setAttr ($multNode+".vectorMultiply") true; setAttr ($multNode+".inPoint") -type "double3" $point[0] $point[1] $point[2]; setAttr ($multNode+".inMatrix") -type "matrix" $matrix[0] $matrix[1] $matrix[2] $matrix[3] $matrix[4] $matrix[5] $matrix[6] $matrix[7] $matrix[8] $matrix[9] $matrix[10] $matrix[11] $matrix[12] $matrix[13] $matrix[14] $matrix[15]; // get the result and delete the node since it is no longer required // $result = `getAttr ($multNode+".output")`; delete $multNode; return $result; }