Hello hugs-bugs-request,
Sunday, March 23, 2003, 4:25:54 AM, you wrote:
The following program:
------------------------------------
module StringSolver(
fixedp,
freep,
connstr,
solvestrings
) where
-- start end length needed
data ConnStr = ConnStr Int Int Double
type V3 = (Double,Double,Double)
data Point =
FixedP V3 -- point that cannot move
| FreeP V3 -- point that we compute.
deriving Show
connstr = ConnStr
fixedp = FixedP
freep = FreeP
step = 0.01
deltasq = d*d
where
d = step
verysmall = 0.000000000000001
sub3v (x,y,z) (x',y',z') = (x-x',y-y',z-z')
add3v (x,y,z) (x',y',z') = (x+x',y+y',z+z')
mul3vsc (x,y,z) sc = (x*sc,y*sc,z*sc)
inprod (x,y,z) (x',y',z') = x*x'+y*y'+z*z'
distsq a b = let d=sub3v a b in inprod d d
dist a b = sqrt $ distsq a b
lenv3 = dist (0,0,0)
normv3 a = let
d = lenv3 a
n = 1/sqrt(d)
in
if d