Sierpinski再一次,这次遵循概率规则。
李,在你的允许下,我用了你的两个套路——正如预期的那样,谢谢!
- (defun c:Sierpinski()
- (setq v (list '(1 1 0) '(0 1 1) '(1 0 1) '(0 0 0))) ;vertices
- (repeat 500
- (setq point (list (LM:randrange -2 2) (LM:randrange -2 2) (LM:randrange -2 2)))
- (repeat 25 (setq point (next point)))
- (repeat 500
- (setq point (next point))
- (entmake (list (cons 0 "POINT")
- (cons 10 point)
- (cons 62 (fix (apply '+ (mapcar '* '(3 9 40 111) (mapcar 'distance (list point point point point) v)))))))
- )
- )
- )
- (defun next (p)
- (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p (nth (LM:randrange 0 3) v)))
- )
-
- ;; Rand - Lee Mac
- ;; PRNG implementing a linear congruential generator with
- ;; parameters derived from the book 'Numerical Recipes'
- (defun LM:rand ( / a c m )
- (setq m 4294967296.0
- a 1664525.0
- c 1013904223.0
- $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
- )
- (/ $xn m)
- )
- ;; Random in Range - Lee Mac
- ;; Returns a pseudo-random integral number in a given range (inclusive)
- (defun LM:randrange ( a b )
- (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b))))))
- )
|