// =========================================================================== // 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. // =========================================================================== // // Description : // To make a polygonal tetrahedron. // given the length of the edge. // proc float boundingSphereRadius( float $side ) { float $rad ; $rad = $side / sqrt(3.0) ; return $rad ; } global proc int polyTetrahedron( float $side ) { float $r = boundingSphereRadius( $side ) ; float $vx[4] ; float $vy[4] ; float $vz[4] ; $vx[0] = $r ; $vy[0] = 0.0 ; $vz[0] = 0.0 ; $vx[1] = -0.5 * $r ; $vy[1] = 0.5 * sqrt(3.0) * $r ; $vz[1] = 0.0 ; $vx[2] = $vx[1] ; $vy[2] = -1.0 * $vy[1]; $vz[2] = 0.0 ; $vx[3] = 0.0 ; $vy[3] = 0.0; $vz[3] = sqrt( $side* $side -$r * $r ) ; // create poly facets. // string $facet1[] ; $facet1 = `polyCreateFacet -ch 0 -p $vx[3] $vy[3] $vz[3] -p $vx[0] $vy[0] $vz[0] -p $vx[1] $vy[1] $vz[1]` ; string $facet2[] ; $facet2 = `polyCreateFacet -ch 0 -p $vx[3] $vy[3] $vz[3] -p $vx[1] $vy[1] $vz[1] -p $vx[2] $vy[2] $vz[2]` ; string $facet3[] ; $facet3 = `polyCreateFacet -ch 0 -p $vx[3] $vy[3] $vz[3] -p $vx[2] $vy[2] $vz[2] -p $vx[0] $vy[0] $vz[0]` ; string $facet4[] ; $facet4 = `polyCreateFacet -ch 0 -p $vx[0] $vy[0] $vz[0] -p $vx[2] $vy[2] $vz[2] -p $vx[1] $vy[1] $vz[1]` ; // unite. // string $tetrahedron[] ; $tetrahedron = `polyUnite -ch 0 $facet1[0] $facet2[0] $facet3[0] $facet4[0]` ; select -r $tetrahedron[0] ; return 0 ; }