vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Solids - Silhouette - Wrong side #380

Closed ameurdefroid closed 1 year ago

ameurdefroid commented 1 year ago

Hello, I am using the solids library and I thank the authors. However, I noticed an error in the projection of an edge.This MWE to explain

triple eye = (1,1,1) ;
triple up = (0,1,0) ;

currentprojection = orthographic(eye, up, O) ;
currentlight = nolight;

// ko
triple direction = (0, -1, 0) ;
// ok
//triple direction = (0, 1, 0) ;

triple cdc = (0,0,-1) ; 
triple Zlocal = unit(cross(cdc, direction)) ;

triple P1 =  -(0.3)*Zlocal- 1/2*direction ;

revolution rExt = revolution(O, P1 -- P1+1*direction, direction, angle1 = 180, angle2 = 360) ;
draw (rExt.silhouette(), red+0.05) ;
draw (surface(rExt), lightblue) ;

When the direction is (0,-1,0), a wrong edge appears while the contour is correct for (0,1,0).

Thanks for your feedback. AM MWE_correct MWE_incorrect

johncbowman commented 1 year ago

Since the silhouette routine is intended only for 2d projections, you need to add these two lines at the beginning of your example:

import solids;
settings.render=0;

As stated in solids.asy, this routine returns an approximate silhouette and is only indended for 2D projections. I'm not even sure what the desired silhouette should look like for this example. It's probably better to draw it by hand, using knowledge specific to the given object.