tk2
25th Aug 2005, 12:05 am
I'm having problems with a program I wrote that models a snail shell based on real measurements from a fossil snail (the measurements are a little off which can be seen after so many rotations but I'm not worried about that part). My problem is with the second half of the code, after the snail is drawn from a series of ellipses I try to use the "rulesurf" command to go back and draw a surface between each ellipse, but it only works for the fist two ellipses (or sometimes three or four which I thought was odd). Because it sometimes works for more than the first two it leads me to believe that my equations are correct and that there may be something touchy about how to use the rulesurf command. So if anyone knows a reason other than a mistake in my equations that might cause it to not work please let me know (are numbers rounded ever?), or if there is a better way to approach the problem.
here is my code and an explanation of whats going on incase it helps (first time using AutoLISP so it might look a little sloppy)
I modeled the snail by creating ellipses each in a new ucs that sweeps along a helico spiral by 10degree incriments.
Variables:
theta is the angle of rotation on the xy-plane
rad defines the radius of a helico spiral on the xy-plane with respect to theta
z defines how the 2d helico spiral is stretched in the z direction for a 3d spiral
Elong is the lenght of the long axis of the ellipse
Eshort is the lenght of the short axis
EllipseXpt is the end point on the long axis of the ellipse
xpos is the positive x-axis direction of the new ucs
ypos is the positive y-axis direction of the new ucs
DDo/x/y coordinates for the new ucs, origin, positive x, and positive y
the second half of the code is supposed draw a surface with rulesurf by selecting a point on the first and second ellipse, second and third ellipse, third and fourth...and so on
(defun c:tkshell()
(setq theta 0
n (* 2 pi (getreal "Enter number of rotations:")))
(setvar "OSMODE" 0)
(while (< theta n)
(setq rad (* 0.0877 (expt 1.1994456838 (/ theta pi)))
z (* -0.3805 (expt 1.20781650039 (/ theta pi)))
Elong (* 0.1338 (expt 1.226257 (/ theta (* 2 pi))))
Eshort (* 0.0775 (expt 1.2088369 (/ theta (* 2 pi))))
EllipseXpt (polar (list 0 0 0) 1.342 Elong)
xpos (+ 1 rad)
ypos (+ 1 z)
DDo (polar (list 0 0 z) theta rad)
DDx (polar (list 0 0 z) theta xpos)
DDy (polar (list 0 0 ypos) theta rad))
(command "ucs" "n" "3" DDo DDx DDy
"ellipse" "c" "0,0,0" EllipseXpt Eshort
"ucs" "w")
(setq theta (+ theta (/ pi 18))))
(setq theta 0
theta2 (/ pi 18))
(command "surftab1" 8)
(while (< theta n)
(setq rad (* 0.0877 (expt 1.1994456838 (/ theta pi)))
z (* -0.3805 (expt 1.20781650039 (/ theta pi)))
Elong (* 0.1338 (expt 1.226257 (/ theta (* 2 pi))))
rad2 (* 0.0877 (expt 1.1994456838 (/ theta2 pi)))
z2 (* -0.3805 (expt 1.20781650039 (/ theta2 pi)))
Elong2 (* 0.1338 (expt 1.226257 (/ theta2 (* 2 pi))))
Zpt1 (+ z (* Elong (sin 1.342)))
RADpt1 (+ rad (* Elong (cos 1.342)))
Zpt2 (+ z2 (* Elong2 (sin 1.342)))
RADpt2 (+ rad2 (* Elong2 (cos 1.342)))
DD1 (polar (list 0 0 Zpt1) theta RADpt1)
DD2 (polar (list 0 0 Zpt2) theta2 RADpt2))
(command "rulesurf" DD1 DD2)
(setq theta (+ theta (/ pi 18))
theta2 (+ theta2 (/ pi 18)))))
so if anyone has any help or suggestions please let me know!
thanks :)
troy
here is my code and an explanation of whats going on incase it helps (first time using AutoLISP so it might look a little sloppy)
I modeled the snail by creating ellipses each in a new ucs that sweeps along a helico spiral by 10degree incriments.
Variables:
theta is the angle of rotation on the xy-plane
rad defines the radius of a helico spiral on the xy-plane with respect to theta
z defines how the 2d helico spiral is stretched in the z direction for a 3d spiral
Elong is the lenght of the long axis of the ellipse
Eshort is the lenght of the short axis
EllipseXpt is the end point on the long axis of the ellipse
xpos is the positive x-axis direction of the new ucs
ypos is the positive y-axis direction of the new ucs
DDo/x/y coordinates for the new ucs, origin, positive x, and positive y
the second half of the code is supposed draw a surface with rulesurf by selecting a point on the first and second ellipse, second and third ellipse, third and fourth...and so on
(defun c:tkshell()
(setq theta 0
n (* 2 pi (getreal "Enter number of rotations:")))
(setvar "OSMODE" 0)
(while (< theta n)
(setq rad (* 0.0877 (expt 1.1994456838 (/ theta pi)))
z (* -0.3805 (expt 1.20781650039 (/ theta pi)))
Elong (* 0.1338 (expt 1.226257 (/ theta (* 2 pi))))
Eshort (* 0.0775 (expt 1.2088369 (/ theta (* 2 pi))))
EllipseXpt (polar (list 0 0 0) 1.342 Elong)
xpos (+ 1 rad)
ypos (+ 1 z)
DDo (polar (list 0 0 z) theta rad)
DDx (polar (list 0 0 z) theta xpos)
DDy (polar (list 0 0 ypos) theta rad))
(command "ucs" "n" "3" DDo DDx DDy
"ellipse" "c" "0,0,0" EllipseXpt Eshort
"ucs" "w")
(setq theta (+ theta (/ pi 18))))
(setq theta 0
theta2 (/ pi 18))
(command "surftab1" 8)
(while (< theta n)
(setq rad (* 0.0877 (expt 1.1994456838 (/ theta pi)))
z (* -0.3805 (expt 1.20781650039 (/ theta pi)))
Elong (* 0.1338 (expt 1.226257 (/ theta (* 2 pi))))
rad2 (* 0.0877 (expt 1.1994456838 (/ theta2 pi)))
z2 (* -0.3805 (expt 1.20781650039 (/ theta2 pi)))
Elong2 (* 0.1338 (expt 1.226257 (/ theta2 (* 2 pi))))
Zpt1 (+ z (* Elong (sin 1.342)))
RADpt1 (+ rad (* Elong (cos 1.342)))
Zpt2 (+ z2 (* Elong2 (sin 1.342)))
RADpt2 (+ rad2 (* Elong2 (cos 1.342)))
DD1 (polar (list 0 0 Zpt1) theta RADpt1)
DD2 (polar (list 0 0 Zpt2) theta2 RADpt2))
(command "rulesurf" DD1 DD2)
(setq theta (+ theta (/ pi 18))
theta2 (+ theta2 (/ pi 18)))))
so if anyone has any help or suggestions please let me know!
thanks :)
troy