10

I want to create a sphere with a grid on it using Asymptote. I have been able to create a sphere with horizontal lines, but I can't find how to make vertical lines. Here's my code so far:

\documentclass[12pt]{article}
\usepackage{asymptote}

\begin{document}
\begin{figure}
\begin{asy}
//import three;
import solids;
unitsize(2.5inch);
//size(5inch);

settings.render=0;
settings.prc=false;

currentprojection=orthographic(3, 1, 1);
currentlight=nolight;

real RE=0.6, RS=0.7, inc=100, lat=45, lon=45, tlat=50, tlon=100;


revolution Earth=sphere(O, RE, n=4*nslice);
draw(surface(Earth), lightgrey+opacity(.4));
draw(Earth,m=10,gray);

\end{asy}
\end{figure}
\end{document}

How can I add vertical lines?

8

I have a solution of sorts. The idea is that when drawing the shaded surface, you should specify the surfacepen and the meshpen separately, so that the mesh (i.e., the grid) will be drawn to be visible. To make the output reasonable, I also increased the opacity of the surface so that it's easier to tell which lines are in front and which are in back.

Unfortunately, if you really want the dotted lines in back as provided by the skeleton, this solution does not cut it.

\documentclass[12pt]{article}
\usepackage{asymptote}

\begin{document}
\begin{figure}
\begin{asy}
//import three;
import solids;
unitsize(2.5inch);
//size(5inch);

settings.render=0;
settings.prc=false;

currentprojection=orthographic(3, 1, 1);
currentlight=nolight;

real RE=0.6, RS=0.7, inc=100, lat=45, lon=45, tlat=50, tlon=100;


revolution Earth=sphere(0, RE)                 //Removed the specification of n
//Added specification for mesh pen
draw(surface(Earth), surfacepen=lightgrey+opacity(.6), meshpen=0.6*white);
//The next line is no longer necessary.
//draw(Earth,m=10,gray);

\end{asy}
\end{figure}
\end{document}

output: enter image description here [Note: The enlarged size is a result of my creating the png file with Apple Previewer at double the resolution for fear of graininess; it has nothing to do with Asymptote.]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.