well, i use newLISP for prototyping some useless functions.
only time will say if the functions are actually usefull and how they eventually are.
the functions manipulate LEGO bricks, represent them as cubes, and test if they overlap and if they connect:
Code: Select all
(constant 'black 0)
(constant 'blue 1)
(constant 'green 2)
(constant 'red 4)
(constant 'brown 6)
(constant 'grey 7)
(constant 'dark 8)
(constant 'yellow 14)
(constant 'white 15)
(constant 'trans 32)
(context 'BRICK)
(set 'num '3001)
(set 'col MAIN:red)
(set 'apos 0)
(set 'xpos 0)
(set 'ypos 0)
(set 'zpos 0)
(set 'xmin -40)
(set 'xmax 40)
(set 'ymin 0)
(set 'ymax 24)
(set 'zmin -20)
(set 'zmax 20)
(define (overlap? b)
(if
(>= xmin b:xmax) nil
(<= xmax b:xmin) nil
(>= ymin b:ymax) nil
(<= ymax b:ymin) nil
(>= zmin b:zmax) nil
(<= zmax b:zmin) nil
true
)
)
(define (connect? b)
(if
(>= xmin b:xmax) nil
(<= xmax b:xmin) nil
(>= zmin b:zmax) nil
(<= zmax b:zmin) nil
(= ymin b:ymax) true
(= ymax b:ymin) true
nil
)
)
(define (move dx dz)
(inc 'xpos dx) (inc 'xmin dx) (inc 'xmax dx)
(inc 'zpos dz) (inc 'zmin dz) (inc 'zmax dz)
)
(define (elevate dy)
(inc 'ypos dy) (inc 'ymin dy) (inc 'ymax dy)
)
(define (rotate-0)
(inc 'apos 90)
(if (= apos 360) (set 'apos 0))
(let (xneg (- xpos)) (set 'xpos zpos) (set 'zpos xneg))
(let (nmin (- xmin) nmax (- xmax))
(set 'xmin zmin) (set 'xmax zmax)
(set 'zmin nmax) (set 'zmax nmin)
)
)
(define (rotate-c x0 z0)
(move (- x0) (- z0)) (rotate-0) (move x0 z0)
)
(define (display)
(print 1) (print " ")
(print col) (print " ")
(print xpos) (print " ")
(print ypos) (print " ")
(print zpos) (print " ")
(if
(= apos 0) (print "1 0 0 0 1 0 0 0 1")
(= apos 90) (print "0 0 1 0 1 0 -1 0 0")
(= apos 180) (print "-1 0 0 0 1 0 0 0 -1")
(= apos 270) (print "0 0 -1 0 1 0 1 0 0")
)
(print " ")
(print num) (print ".dat")
(print "\r\n")
)
the "display" output is valid entry for LEGO-CAD software that can be found here:
http://www.ldraw.org/
"1 0 0 0 1 0 0 0 1" is not binary number but the identity matrix:
1 0 0
0 1 0
0 0 1
newLISP has matrix operations and that is also a welcomed plus :-)
i guess prototyping languages are ideal for such experiments, when you are not sure what you want to do, but you know how to do it.
newLISP is open-minded :-)