// =========================================================================== // 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: 14 April 1998 // // // // // int floatArrayEq(float $lhs[], float $rhs[], float $tolerance) // // // This script compares two float arrays to determine they are // equal within a hard-coded limit. // // // float[] $lhs First array to be compared // float[] $rhs Second array to be compared // float $tol Tolerance for array members to be judged equal // // // int : 1 if all members of float arrays are equal within $tol, else 0. // // // float $lhs[] = { 1.0, 2.0, 3.0 }; // float $rhs[] = { 1.1, 2.1, 2.9 }; // floatArrayEq( $lhs, $rhs, 0.01 ); // // Result : 0 // // floatArrayEq( $lhs, $rhs, 0.2 ); // // Result : 1 // // // // // ========== floatArrayEq ========== // // SYNOPSIS // This script checks two float arrays to determine they are equal. // global proc int floatArrayEq( float $faLhs[], float $faRhs[], float $tolerance ) { int $lengthLhs = size( $faLhs ); int $lengthRhs = size( $faRhs ); if ( $lengthLhs != $lengthRhs ) { return false; } for ( $i = 0; $i < $lengthLhs; $i++ ) { if ( ! (abs( $faLhs[$i] - $faRhs[$i] ) < $tolerance) ) { return false; } } return true; } // floatArrayEq //