PDA

View Full Version : creating a surface with "rulesurf" command

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

&#40;defun c&#58;tkshell&#40;&#41;
&#40;setq theta 0
n &#40;* 2 pi &#40;getreal "Enter number of rotations&#58;"&#41;&#41;&#41;
&#40;setvar "OSMODE" 0&#41;
&#40;while &#40;< theta n&#41;
&#40;setq rad &#40;* 0.0877 &#40;expt 1.1994456838 &#40;/ theta pi&#41;&#41;&#41;
z &#40;* -0.3805 &#40;expt 1.20781650039 &#40;/ theta pi&#41;&#41;&#41;
Elong &#40;* 0.1338 &#40;expt 1.226257 &#40;/ theta &#40;* 2 pi&#41;&#41;&#41;&#41;
Eshort &#40;* 0.0775 &#40;expt 1.2088369 &#40;/ theta &#40;* 2 pi&#41;&#41;&#41;&#41;
EllipseXpt &#40;polar &#40;list 0 0 0&#41; 1.342 Elong&#41;
xpos &#40;+ 1 rad&#41;
ypos &#40;+ 1 z&#41;
DDo &#40;polar &#40;list 0 0 z&#41; theta rad&#41;
DDx &#40;polar &#40;list 0 0 z&#41; theta xpos&#41;
DDy &#40;polar &#40;list 0 0 ypos&#41; theta rad&#41;&#41;
&#40;command "ucs" "n" "3" DDo DDx DDy
"ellipse" "c" "0,0,0" EllipseXpt Eshort
"ucs" "w"&#41;
&#40;setq theta &#40;+ theta &#40;/ pi 18&#41;&#41;&#41;&#41;

&#40;setq theta 0
theta2 &#40;/ pi 18&#41;&#41;
&#40;command "surftab1" 8&#41;
&#40;while &#40;< theta n&#41;
&#40;setq rad &#40;* 0.0877 &#40;expt 1.1994456838 &#40;/ theta pi&#41;&#41;&#41;
z &#40;* -0.3805 &#40;expt 1.20781650039 &#40;/ theta pi&#41;&#41;&#41;
Elong &#40;* 0.1338 &#40;expt 1.226257 &#40;/ theta &#40;* 2 pi&#41;&#41;&#41;&#41;
rad2 &#40;* 0.0877 &#40;expt 1.1994456838 &#40;/ theta2 pi&#41;&#41;&#41;
z2 &#40;* -0.3805 &#40;expt 1.20781650039 &#40;/ theta2 pi&#41;&#41;&#41;
Elong2 &#40;* 0.1338 &#40;expt 1.226257 &#40;/ theta2 &#40;* 2 pi&#41;&#41;&#41;&#41;
Zpt1 &#40;+ z &#40;* Elong &#40;sin 1.342&#41;&#41;&#41;
RADpt1 &#40;+ rad &#40;* Elong &#40;cos 1.342&#41;&#41;&#41;
Zpt2 &#40;+ z2 &#40;* Elong2 &#40;sin 1.342&#41;&#41;&#41;
RADpt2 &#40;+ rad2 &#40;* Elong2 &#40;cos 1.342&#41;&#41;&#41;
DD1 &#40;polar &#40;list 0 0 Zpt1&#41; theta RADpt1&#41;
DD2 &#40;polar &#40;list 0 0 Zpt2&#41; theta2 RADpt2&#41;&#41;
&#40;command "rulesurf" DD1 DD2&#41;
&#40;setq theta &#40;+ theta &#40;/ pi 18&#41;&#41;
theta2 &#40;+ theta2 &#40;/ pi 18&#41;&#41;&#41;&#41;&#41;

so if anyone has any help or suggestions please let me know!
thanks :)
troy

CarlB
25th Aug 2005, 01:18 am
The problem may be in selecting the ellipse for the rulesurf command. Suppling an "entity selection" type of list (like returned by "entsel") rather than just a point should be less error prone.

After drawing the ellipses, save their name, e.g:

(setq Ename1 (entlast))

then for the rulesurf command use:

(command "rulesurf" (list Ename1 DD1) (list Ename2 DD2))

tk2
28th Aug 2005, 08:06 pm
hey thanks for the help! i really appreciate it.
troy