\ newtonian equations & functions \ \ hp_util \ functions used as part of the collection of software componenets: \ "henri poincare." \ \ based on ideas presented by Joel Ryan. \ \ Code: Han-earl Park \ Copyright 2000 Buster & Friends C-ALTO Labs \ (Den haag, December 1997 - \ (Valencia, October 1998 - \ \ MOD: HeP 10/15/98 Change name of the collective software components \ to "forces in motion". \ MOD: HeP 11/19/98 Chage name of file to fim_util \ MOD: HeP 11/29/98 Can't find my copy of the fixed point SQRT so build one \ from scratch. \ MOD: HeP 11/30/98 Use the sqrt implemetation by Wil Baden found in \ Julian V. Noble's "forth primer". \ MOD: HeP 12/13/98 Get rid of the aliases of vec->abs. \ MOD: HeP 07/27/99 Change name of components to "henri poincare" anew task-hp_util variable nfunc-dimensions : #DIMENSIONS! ( n -- , set current number of dimensions ) nfunc-dimensions ! ; : #DIMENSIONS@ ( -- n , retrieve number of dimensions ) nfunc-dimensions @ ; \ square and square root : SQUARE ( n -- n*n , square value ) dup * ; \ the word SQRT is taken from Julian V. Noble's "forth primer" \ and is based on an routine by Wil Baden. : SQRT ( n -- rt , calculate square root of n ) 0 swap 0 \ set n as tthe limit DO 1+ dup 2* 1+ \ 2n+1 +LOOP \ add 2n+1 to sum and loop if less than n ; \ newton's second "law": dv = f / m : FM->DV ( force mass -- dvelocity , calculate acceleration ) / ; \ calculate vector components \ convert vectored values to absolute form \ \ |n| = sqrt( x*x + y*y + z*z + ... ) \ : VEC->ABS*ABS ( x y z... -- |n*n| , vector components to squared magnitude ) 0 #dimensions@ 0 DO swap ( x y z 0 -- x y 0 z ) square ( x y 0 z -- x y 0 z*z ) + ( x y 0 z*z -- x y z*z ) LOOP ; : VEC->ABS ( x y z... -- |n| , convert from vectored to absolute values ) vec->abs*abs sqrt ;