Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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