\ newtonian equations & functions
\
\ hp_fputil
\ floating point versions of code in hp_util. part of the componenets:
\ "henri poincare."
\
\ based on ideas presented by Joel Ryan.
\
\ code: Han-earl Park
\ copyright 2004 buster & friends' C-ALTO Labs
\ (Den haag, December 1997 -
\ (Valencia, October 1998 -
\ (Southampton, March 2004 -
\
\ 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"
\ MOD: HeP 03-18-04 Begin convertion to floating point.
\ MOD: HeP 03-19-04 First working floating point version.
\ MOD: HeP 03-20-04 Move floating point code to separate file.
include? task-floatingpoint hsys:floatingpoint
include? task-hp_util myt:hp_util
anew task-hp_fputil
\ square and square root
: FSQUARE ( r -f- r*r , square value )
fdup f*
;
\ FSQRT ( r -f- sqrt(r) )
\ newton's second "law": dv = f / m
: FFM->DV ( force -f- dvelocity , mass -- , calculate acceleration )
i>f \ convert fixed point mass to float
f/ \ force mass -f- dvelocity
;
\ convert vectored values to absolute form
\
\ |n| = sqrt( x*x + y*y + z*z + ... )
\
: FVEC->ABS*ABS ( x y z... -f- |r*r| , vector components to squared magnitude )
0 i>f
#dimensions@ 0
DO
fswap \ x y z 0 -f- x y 0 z
fsquare \ x y 0 z -f- x y 0 z*z
f+ \ x y 0 z*z -f- x y z*z
LOOP
;
: FVEC->ABS ( x y z... -f- |r| , convert from vectored to absolute values )
fvec->abs*abs
fsqrt
;