Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;-----------------=={ Julia Set Fractal }==------------------;;
- ;; ;;
- ;; The function will create a representation of the Julia ;;
- ;; set by iteration of the function: ;;
- ;; ;;
- ;; f(z) = z^2 + c ;;
- ;; ;;
- ;; Where 'z' & 'c' are complex numbers. The fractal colour ;;
- ;; is determined by the number of iterations (less than a ;;
- ;; predetermined maximum iteration number) before the ;;
- ;; norm of the complex number generated by the above ;;
- ;; function reaches a limit. ;;
- ;; ;;
- ;; 'c' is the constant for each calculation, this ;;
- ;; distinguishes the Julia set from the Mandelbrot set ;;
- ;; (in which 'c' is set to the complex values of each point) ;;
- ;; For this reason, there are infinitely many Julia fractals,;;
- ;; but only one Mandelbrot fractal. ;;
- ;; ;;
- ;; More interestingly, there exists a Julia fractal for ;;
- ;; every point of the Mandelbrot fractal. ;;
- ;;------------------------------------------------------------;;
- ;; Note: ;;
- ;; -------- ;;
- ;; Fractal calculation is CPU intensive and may take a ;;
- ;; long time to generate the result. Reduce the iteration ;;
- ;; limit and image size & resolution to decrease calculation ;;
- ;; time. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
- ;;------------------------------------------------------------;;
- (defun c:jfract ( / a b c i im[c] lim re[c] res x xmax xmin y ymax ymin )
- (setvar 'PDMODE 0)
- (setq
- lim 255 ;; Iteration Limit
- xmin -0.60 ;; }
- xmax -0.30 ;; | Image
- ymin -0.35 ;; | Size
- ymax -0.05 ;; }
- res 0.0025 ;; Image Resolution
- Re[c] 0.285 ;; Real Coefficient of Julia Constant
- Im[c] 0.01 ;; Imaginary Coefficient of Julia Constant
- )
- (setq x (- xmin res))
- (while (<= (setq x (+ x res)) xmax)
- (setq y (- ymin res))
- (while (<= (setq y (+ y res)) ymax)
- (setq
- i 0
- a x
- b y
- )
- (while
- (and
- (< (+ (* a a) (* b b)) 4.)
- (<= (setq i (1+ i)) lim)
- )
- (setq
- c (* 2.0 a b)
- a (+ (- (* a a) (* b b)) Re[c])
- b (+ c Im[c])
- )
- )
- (entmake
- (list
- '(0 . "POINT")
- (list 10 x y)
- (cons 62 (1+ (rem (+ 30 i) 255)))
- )
- )
- )
- )
- (princ)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement