Jump to content

Recommended Posts

Posted (edited)

Found it, big thanks to Kent Cooper for original code. May need this for it to work with image.

(command "imageattach" "santa sleigh.png" "50,50,50" 5.0 90.)

 

 

santa sleigh.png

 

The challenge now is Halloween. 

Edited by BIGAL
Posted
On 10/12/2024 at 1:27 AM, BIGAL said:

Found it, big thanks to Kent Cooper for original code. May need this for it to work with image.

(command "imageattach" "santa sleigh.png" "50,50,50" 5.0 90.)

 

 

OR you could add some code so that the lisp draws the tree AND the Santa!

Posted

Check my post on page 1 for the tree code.

 

 

Posted
On 10/10/2024 at 1:22 PM, Steven P said:

am blatantly stealing the mouse!

See here a better mouse:

(defun c:mouse()
  (setq db (list -199.62 -5.44 36.3 3.8 5.9 -191.1 -67.0 54.17 1.09 2.33 -754.94 -667.83 700.5 1.02 1.3 -697.51 -324.45 413.77 0.71 1.1 -947.87 -457.31
		 707.22 0.63 0.81 -366.01 -678.05 584.44 1.16 1.5 -265.54 -967.4 894.62 1.39 1.65 -87.11 58.07 90.74 5.9 0.6 47.68 136.17 65.64 1.87 3.56
		 471.35 -156.12 201.95 1.13 2.0 564.74 45.02 19.86 4.35 5.29 557.17 57.36 34.34 5.28 0.87 637.13 141.41 81.76 3.15 3.93 592.55 141.13
		 37.18 2.2 3.15 572.44 167.6 4.02 5.85 2.0 621.24 137.96 53.11 2.59 4.06 551.2 33.18 73.11 0.19 1.03 572.45 39.75 51.06 4.65 0.15 579.97
		 276.34 287.74 4.5 4.67 477.39 -183.44 183.35 1.34 2.1 49.25 -106.66 265.1 5.88 6.09 303.86 -216.14 12.06 2.77 5.38 255.21 -153.01 91.76
		 5.37 5.69 364.68 -201.21 33.36 2.9 4.18 352.84 -213.17 17.58 4.43 0.24 415.72 -175.59 56.7 3.32 4.14 391.99 -210.51 14.52 4.2 0.34 276.69
		 -270.79 144.49 0.47 0.87 493.12 -25.69 182.54 3.73 3.97 -68.96 -43.55 145.18 5.0 5.9 -141.7 309.86 505.64 4.54 4.94 -19.43 178.0 252.79
		 2.9 3.42 -213.13 215.88 56.49 0.56 2.73 -283.1 181.48 134.29 6.2 0.5 -304.88 -123.4 101.63 3.5 0.2 -330.29 -130.66 76.22 2.7 3.5 99.25
		 -271.7 527.82 2.41 2.81 -32.91 -177.85 367.13 1.55 2.37 -188.74 -214.14 68.96 5.4 6.1 -101.39 -312.24 62.5 2.34 2.89 -151.26 -300.55
		 11.37 2.77 4.97 -152.96 -296.75 15.5 5.02 6.15 -90.48 -301.31 47.18 2.7 3.6 -120.07 -316.43 13.97 3.57 6.22 -28.19 -296.7 80.6 2.85 3.47
		 -98.0 -319.4 7.26 3.6 5.8 -137.12 -301.39 50.32 5.84 0.01 90.74 -290.36 177.85 3.1 3.2 -68.78 -299.39 18.08 3.22 5.07 -69.87 -302.96 15.27
		 5.21 0.86 32.65 -214.32 120.46 3.62 3.84 -42.45 -250.03 37.45 2.84 3.69 17.55 153.72 404.25 4.18 4.8 58.76 -264.74 16.49 0.64 1.84 39.92
		 -261.33 32.67 5.0 0.2 25.81 -151.6 142.97 4.62 4.88 10.79 -336.9 42.95 1.52 2.91 -20.4 -330.07 11.04 2.86 4.79 -22.96 -310.9 30.37 4.82
		 5.56 69.89 -369.77 80.08 2.19 2.69 10.89 -341.18 14.52 2.7 5.3 -11.28 -287.53 72.34 5.14 5.6 87.11 -342.99 43.55 2.2 3.3 56.58 -349.43
		 12.49 3.18 6.19 108.36 -349.04 39.37 2.23 3.18 88.97 -326.19 9.54 6.03 2.08 104.98 -330.53 7.06 2.86 0.28 195.29 -307.68 86.09 1.9 3.39
		 107.09 -72.36 165.28 5.09 0.56 29.04 112.52 108.89 4.6 5.9 -95.86 166.16 244.59 5.81 0.04 87.11 170.59 61.7 0.1 1.9 121.8 -22.59 257.44
		 1.78 2.42 -424.65 -140.1 54.44 5.5 1.0 166.96 10.89 221.4 4.87 1.8 -355.21 -396.57 285.04 0.89 1.45))
  (setq i 0)
  (repeat 76
    (entmake (list (cons 0 "ARC") (list 10 (nth i db) (nth (1+ i) db)) (cons 40 (nth (+ 2 i) db)) (cons 50 (nth (+ 3 i) db)) (cons 51 (nth (+ 4 i) db))))
    (setq i (+ 5 i))
    )
  )

 

Credit for the mouse

Posted

And an other one:

(defun c:mouse2()
  (setq db (list -113.57 -729.5 798.34 0.94 1.21 94.77 -182.15 212.71 1.23 1.63 -273.44 -1127.05 1216.32 1.03 1.18 116.75 -183.15 194.97 1.19 1.75 -208.71
		 42.95 293.05 6.0 6.17 -613.37 -105.85 688.61 6.28 0.11 115.79 -107.61 40.55 3.13 3.92 93.1 -168.57 33.0 1.37 1.76 85.93 -173.84 40.06 0.89
		 1.22 109.62 -144.37 2.26 4.24 0.85 98.2 -155.14 13.59 0.7 1.5 114.61 -143.62 6.63 3.57 4.64 113.51 -153.2 3.03 4.51 1.37 117.55 -139.2 17.59
		 3.9 4.44 97.51 -159.38 10.87 0.84 1.79 86.07 -156.14 11.77 0.1 1.37 94.54 -155.62 3.3 3.59 0.2 83.65 -158.76 8.1 0.21 1.8 74.15 -151.36 7.21
		 5.69 0.4 77.39 -153.76 3.19 3.28 5.75 66.58 -155.24 7.72 0.13 1.48 68.55 -139.53 8.13 2.32 4.55 -77.94 -181.26 148.83 0.33 0.55 15.42 -123.27
		 38.93 0.55 1.15 15.78 -59.74 37.78 4.58 5.31 37.55 50.8 150.38 4.35 4.53 89.5 -213.53 162.38 2.28 2.58 -20.68 -148.2 34.58 2.46 3.31 -42.62
		 -152.04 12.31 3.29 4.03 -51.76 -163.22 2.13 4.33 0.85 -40.51 -151.41 18.31 3.4 3.99 -39.83 -159.4 15.85 3.3 3.86 -53.51 -171.58 2.48 3.73
		 0.79 -982.19 -966.04 1219.67 0.71 0.72 -64.23 -168.62 3.98 1.08 3.3 -292.97 -204.07 227.49 0.13 0.15 -70.16 -175.13 2.92 3.26 0.41 -51.8
		 -169.52 22.07 2.67 3.41 -69.86 -180.59 15.67 1.8 2.71 -86.6 -172.95 2.72 3.02 5.89 -75.36 -173.55 13.98 2.1 3.07 -84.46 -155.24 6.57 5.03 5.78
		 -90.46 -155.03 11.03 4.4 5.06 -93.36 -163.9 1.7 2.21 4.43 -80.49 -176.78 19.89 1.81 2.34 -92.26 -139.21 19.57 5.08 5.96 -315.33 -53.23 258.62
		 5.92 6.2 61.88 -64.14 119.86 2.81 3.23 1.98 16.56 80.74 6.19 3.92 4.69 0.88 54.47 0.94 2.37 0.88 10.86 12.16 3.23 6.05 -13.02 -6.5 13.34 4.44
		 0.23 15.89 -3.73 15.94 3.12 4.92 0.7 -13.77 9.85 4.03 5.43 4.5 11.76 50.33 3.28 6.28 -11.93 -1.61 15.31 2.5 3.76 15.24 -0.57 16.67 5.35 0.71
		 -4.12 4.54 1.13 1.77 1.37 6.23 5.22 1.13 1.77 1.37 25.12 57.62 8.51 5.13 0.02 51.42 56.09 17.88 6.23 3.04 24.98 54.54 44.3 5.39 0.01 -44.91
		 54.89 19.74 1.1 2.98 -19.13 57.09 16.06 2.78 4.09 -23.59 57.52 40.81 3.13 4.28 -39.88 66.75 6.96 5.69 0.96 -24.11 29.69 1.13 1.77 1.37 28.78
		 29.69 1.13 1.77 1.37 -25.29 26.1 8.72 0.56 3.39 -30.28 37.74 14.25 4.47 5.77 27.64 27.4 8.77 5.88 2.38 34.15 37.31 13.43 3.43 4.83 87.13 -58.38
		 15.21 3.68 4.84 89.89 -85.68 12.25 0.98 1.64 121.05 -44.63 39.31 4.05 4.39 107.91 -84.16 2.36 4.64 1.35 110.91 -58.18 28.51 4.16 4.6 83.87 -102.85
		 23.7 1.03 1.35 84.62 -92.52 13.55 0.4 1.24 105.46 -85.2 8.62 3.37 4.51 102.82 -99.3 5.73 0.3 1.41 104.98 -97.96 3.32 4.62 0.11 106.81 -87.68 13.76
		 3.89 4.56 76.98 -110.46 23.87 0.6 1.22 73.7 -107.01 22.17 0.36 1.03 90.91 -100.72 3.85 3.5 0.39 71.14 -107.54 17.06 0.33 1.05 98.51 -93.62 18.9
		 3.1 3.42 77.84 -99.72 2.67 3.33 0.37 -85.27 -36.48 25.07 5.37 0.06 -51.78 -100.25 47.54 1.96 2.39 -92.97 -60.86 9.48 4.72 5.46 -93.14 -73.23 2.9
		 1.5 4.69 -92.37 -63.06 13.08 4.65 5.24 -82.23 -80.02 6.67 1.45 2.13 -71.84 -81.22 12.38 1.89 3.05 -93.68 -78.56 9.63 5.24 6.12 -87.39 -89.5 2.99
		 2.06 5.51 -194.96 -9.33 137.12 5.64 5.73 -63.57 -86.47 15.58 2.3 3.54 -74.75 -91.73 3.28 3.36 0.21 -59.23 -87.0 12.95 2.14 3.46 -64.87 -76.93 1.59
		 5.64 2.6 -55.9 -82.49 8.97 2.6 3.93 -60.84 -87.65 1.83 3.88 6.0 353.88 -83.67 1.12 4.13 0.73))
  (setq i 0)
  (repeat 106
    (entmake (list (cons 0 "ARC") (list 10 (nth i db) (nth (1+ i) db)) (cons 40 (nth (+ 2 i) db)) (cons 50 (nth (+ 3 i) db)) (cons 51 (nth (+ 4 i) db))))
    (setq i (+ 5 i))
    )
  )

The original raster image is from the same place as the previous one.

Posted

More mice will need more cheese

(defun c:cheese()
  (setq db (list 0.0 0.0 -5.0 0.0 0.7 0.0 3.14 0.0 2.9 5.0 0.0 0.7 0.84 6.28 1.39 3.97 5.0 0.0 0.7 6.27 7.12 1.45 3.52 -0.14 -0.03 0.53 1.0 5.08 2.34
3.25 -0.1 0.03 0.62 0.0 6.28 3.27 3.64 -0.17 -0.01 0.5 0.0 6.28 4.68 3.16 -0.13 0.03 0.59 0.0 6.28 5.68 3.48 -0.1 0.02 0.53 0.0 6.28 5.79 2.71 -0.12
-0.04 0.57 0.0 6.28 5.45 1.86 -0.08 -0.04 0.45 0.0 6.28 6.05 1.34 -0.11 0.02 0.52 0.0 6.28 1.36 3.33 -0.1 -0.09 0.52 4.0 7.71 0.84 3.13 -0.07 -0.1 0.45 0.0 6.28))
  (setq i 0)
  (repeat 13
    (entmake (list '(0 . "ELLIPSE") '(100 . "AcDbEntity") '(67 . 0)'(100 . "AcDbEllipse") (list 10 (nth i db) (nth (1+ i) db)) 
(list 11 (nth (+ 2 i) db) (nth (+ 3 i) db)) (cons 40 (nth (+ 4 i) db)) (cons 41 (nth (+ 5 i) db)) (cons 42 (nth (+ 6 i) db))))
    (setq i (+ 7 i))
    )
  (setq db (list -5.0 0.0 -5.0 2.9 5.0 0.0 5.0 2.9 0.0 2.9 3.35 5.49 0.0 2.9 5.0 2.9 1.39 3.97 1.39 3.58 5.0 1.05 6.39 1.03 6.39 1.03 6.39 3.93 6.39
3.93 1.39 3.97 0.0 2.9 4.73 6.57 1.39 3.44 1.39 2.9) i 0)
  (repeat 10
    (entmake (list '(0 . "LINE") (list 10 (nth i db) (nth (1+ i) db)) (list 11 (nth (+ 2 i) db) (nth (+ 3 i) db))))
    (setq i (+ 4 i))
    )
  )

 

Posted (edited)

Salut fuccaro

 

The function you are looking for is a logarithmic spiral. Starting in the unit circle, the parametric equations of the spiral are:

x(a)=(q^a)*cos(a)

y(a)=(q^a)*sin(a)

where q= e^(-tan(pi/n)) and q^a is the distance from the center to the mouse

and n is the number of mice.

The angle a is in range 0...∞

For n=3...∞, q < 1. That means, q^a=0 at a=∞. The mice would never reach the center!!!

If k=tan(pi/n), the length of the trajectory is sqrt(k^2+1)/k, which is a finite number!!!

Half of the length is reached at r=0.5!

 

Strange enough, for n=10 the length is 2 times the golden ratio.

 

(defun mice ( n / rot a b c q da r l)
  (defun rot (p a)
    (list
      (apply '- (mapcar '* p (list (cos a) (sin a))))
      (apply '+ (mapcar '* p (list (sin a) (cos a))))
    )
  )
  
  (setq b (/ (* 2 pi) n))
  
  (setq q (exp (/ (- (sin (/ b 2))) (cos (/ b 2)))))

  (setq a 0.0 da (/ pi 180))

  (repeat 721
    (setq r (expt q a)
          l (cons
               (list
                 (* r (cos a))
                 (* r (sin a))
               )
               l
             )
          a (+ a da)
    )
  )

  (entmakex '((0 . "CIRCLE") (10 0.0 0.0 0.0) (40 . 1.0)))
  
  (draw_spline
    l
    (setq c 1)
  )
  
  (repeat (1- n)
    (draw_spline
      (setq l (mapcar '(lambda (p) (rot p b)) l))
      (setq c (1+ c))
    )
  )
)


(defun draw_spline (pts color)
  (entmakex
    (append
      (list
       '(0 . "SPLINE")
       '(100 . "AcDbEntity")
       '(100 . "AcDbSpline")
        (cons 62 color)
       '(70 . 1064)
       '(71 . 3)
        (cons 74 (length pts))
      )
      (mapcar
       '(lambda (x)
          (cons 11 x)
        )
        pts
      )
    )
  )
)

 

 

 

 

 

 

Edited by Stefan BMR
  • Like 1
Posted

@Stefan BMR

A late "thank you" for taking time to answering me.

 

mulțumesc

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...