Difference between pages "Recursion" and "ReturnNVectorCOG"
From scripting
(Difference between pages)
(Created page with " <div align="right">Back to Academic_Archives.</div> __TOC__ ===In Progress=== ===Important Links=== [http://www.idi.ntnu.no/~fredrior/files/Catmull-Clark%201978%20Re...") |
(Created page with " global proc vector ReturnNVectorCOG(vector $AllVecs[]) { //Author Nick Pisca 0001d 2010 //$AllVecs[0]=<<0,0,0>>;$AllVecs[1]=<<1,-1,0>>;$AllVecs[2]=<<1,0,0>>;$AllVecs[3]=<...") |
||
Line 1: | Line 1: | ||
+ | global proc vector ReturnNVectorCOG(vector $AllVecs[]) { | ||
+ | //Author Nick Pisca 0001d 2010 | ||
+ | //$AllVecs[0]=<<0,0,0>>;$AllVecs[1]=<<1,-1,0>>;$AllVecs[2]=<<1,0,0>>;$AllVecs[3]=<<0,0,2>>; | ||
+ | vector $TempVec = <<0,0,0>>; | ||
+ | if (size($AllVecs) != 0 ) { | ||
+ | for ($i=0;$i<size($AllVecs);$i++) { | ||
+ | $TempVec = $TempVec + $AllVecs[$i]; | ||
+ | } | ||
+ | $TempVec = $TempVec / size($AllVecs); | ||
+ | } | ||
+ | return $TempVec; | ||
+ | } | ||
− | |||
− | |||
− | |||
− | + | ''More information on vectors and vector mathematics, read pages 14-16, 20-21 in [http://stores.lulu.com/nickpisca YSYT]. | |
− | + | [[Category:MEL]] | |
− | |||
− | [http:// | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 19:56, 24 April 2017
global proc vector ReturnNVectorCOG(vector $AllVecs[]) { //Author Nick Pisca 0001d 2010 //$AllVecs[0]=<<0,0,0>>;$AllVecs[1]=<<1,-1,0>>;$AllVecs[2]=<<1,0,0>>;$AllVecs[3]=<<0,0,2>>; vector $TempVec = <<0,0,0>>; if (size($AllVecs) != 0 ) { for ($i=0;$i<size($AllVecs);$i++) { $TempVec = $TempVec + $AllVecs[$i]; } $TempVec = $TempVec / size($AllVecs); } return $TempVec; }
More information on vectors and vector mathematics, read pages 14-16, 20-21 in YSYT.