4

I copy this code from here

settings.render=8;
import solids;
size(5cm);

currentprojection=orthographic(1,0.3,0.3);

revolution b=sphere(O,1);
draw(surface(b),white+opacity(.5));

skeleton s;
b.transverse(s,reltime(b.g,0.5),P=currentprojection);

draw(s.transverse.back,dashed);
draw(s.transverse.front);
draw(rotate(90,X)*s.transverse.back,dashed);
draw(rotate(90,X)*s.transverse.front);

real rayon=0.8, phi=90, theta=45;
triple pM=dir(phi,theta);

draw((O--pM),dashed+green+0.7bp,Arrow3(size=7));
label(Label("$\psi$",yellow),pM,0.5dir(-90));

xaxis3("$x$",1,1.5,Arrow3);
xaxis3(-1.3,1,linetype(new real[] {8,8}));
yaxis3("$y$",1,1.5,Arrow3);
yaxis3(-1.3,1,linetype(new real[] {8,8}));
zaxis3("$z$",1,1.5,Arrow3);
zaxis3(0,1,linetype(new real[] {8,8}));

and try to compile at here http://asymptote.ualberta.ca/ I rotate output by hand, the result seems incorrect. enter image description here

How can I get the result like this?

enter image description here

1
  • 1
    If you mean interfacing with a mouse, you can't. Changing the image would require recompiling the code. You need to do the whole thing using Javascript. Oct 16, 2021 at 17:21

1 Answer 1

3

As John Kormylo'comment, I think, you can not rotate the sphere with a mouse (if you use TikZ). We hope that, in future, Asymptote can do this (keep automatic dashed lines when we rotate sphere!). You can try this code. I hope, it helps you something.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
    \pgfdeclarelayer{background}
    \pgfdeclarelayer{foreground}
    \pgfsetlayers{background,main,foreground}
\foreach \Angle in {5,15,...,360}
{\begin{tikzpicture}[3d/install view={phi=\Angle,theta=70},line cap=butt,
        line join=round,visible/.style={draw,solid},
        hidden/.style={draw,very thin,cheating dash},declare function={R=5;}]
        \path (0,0,0) coordinate (I)
        foreach \Z in {-75,-60,...,75}
        {(0,0,{R*sin(\Z)}) coordinate (I\Z)}
        foreach \Z in {-75,-60,...,90}
        {({cos(\Z)},{sin(\Z)},0) coordinate (n\Z)};
        \shade[ball color=white,3d/screen coords,opacity=0.8] (I) circle[radius=R];
        %
        \path foreach \Z in {-75,-60,...,90}
        {pic{3d/circle on sphere={R=R,C={(I)},P={(I)},n={(n\Z)},
                    fore layer=foreground,back layer=background}}};
        %
        \path foreach \Z in {-75,-60,...,75}
        {pic{3d/circle on sphere={R=R,C={(I)}, P={(I\Z)},fore layer=foreground,back layer=background}}};
    \end{tikzpicture}}
\end{document}

The output get a big file, I can not upload it at here. I put it here or here

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.