diff options
Diffstat (limited to 'Build/source/utils/asymptote/base/solids.asy')
-rw-r--r-- | Build/source/utils/asymptote/base/solids.asy | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/Build/source/utils/asymptote/base/solids.asy b/Build/source/utils/asymptote/base/solids.asy index 942a7fe233a..2f0a13f4b50 100644 --- a/Build/source/utils/asymptote/base/solids.asy +++ b/Build/source/utils/asymptote/base/solids.asy @@ -115,23 +115,13 @@ struct revolution { return (angle2-angle1) % 360 == 0 ? p&cycle : p; } - triple camera(projection P) { - triple camera=P.camera; - if(P.infinity) { - real s=abs(M-m)+abs(m-P.target); - camera=P.target+camerafactor*s*unit(P.vector()); - } - return camera; - } - // add transverse slice to skeleton s; void transverse(skeleton s, real t, int n=nslice, projection P) { skeleton.curve s=s.transverse; path3 S=slice(t,n); - triple camera=camera(P); int L=length(g); real midtime=0.5*L; - real sign=sgn(dot(axis,camera-P.target))*sgn(dot(axis,dir(g,midtime))); + real sign=sgn(dot(axis,P.camera-c))*sgn(dot(axis,dir(g,midtime))); if(dot(M-m,axis) == 0 || (t <= epsilon && sign < 0) || (t >= L-epsilon && sign > 0)) s.front.push(S); @@ -154,7 +144,7 @@ struct revolution { path3 p1=subpath(S,t1,t2); path3 p2=subpath(S,t2,len); path3 P2=subpath(S,0,t1); - if(abs(midpoint(p1)-camera) <= abs(midpoint(p2)-camera)) { + if(abs(midpoint(p1)-P.camera) <= abs(midpoint(p2)-P.camera)) { s.front.push(p1); if(cyclic(S)) s.back.push(p2 & P2); @@ -212,7 +202,6 @@ struct revolution { for(int i=0; i < M; ++i) { real t=(m == 0) ? i : reltime(g,i*factor); path3 S=slice(t,n); - triple camera=camera(P); path3 Sp=slice(t+epsilon,n); path3 Sm=slice(t-epsilon,n); path sp=project(Sp,P); @@ -232,8 +221,7 @@ struct revolution { } int L=length(g); real midtime=0.5*L; - triple camera=camera(P); - real sign=sgn(dot(axis,camera-P.target))*sgn(dot(axis,dir(g,midtime))); + real sign=sgn(dot(axis,P.camera-c))*sgn(dot(axis,dir(g,midtime))); skeleton sfirst; transverse(sfirst,tfirst,n,P); @@ -293,7 +281,6 @@ struct revolution { real Longitude(triple v) {return longitude(T*(v-c),warn=false);} real ref=Longitude(point(g,t)); real angle(real t) {return Longitude(point(S,t/P.ninterpolate))-ref;} - triple camera=camera(P); void push(real[] T) { if(T.length > 1) { path3 p=rotate(angle(T[0]),c,c+axis)*g; @@ -301,7 +288,7 @@ struct revolution { path3 p2=subpath(p,t,length(p)); if(length(p1) > 0 && (length(p2) == 0 || - abs(midpoint(p1)-camera) <= abs(midpoint(p2)-camera))) { + abs(midpoint(p1)-P.camera) <= abs(midpoint(p2)-P.camera))) { s.longitudinal.front.push(p1); s.longitudinal.back.push(p2); } else { @@ -346,15 +333,15 @@ void draw(picture pic=currentpicture, revolution r, int m=0, int n=nslice, if(is3D()) { pen thin=thin(); void drawskeleton(frame f, transform3 t, projection P) { - skeleton s=(t*r).skeleton(m,n,P); + skeleton s=r.skeleton(m,n,inverse(t)*P); if(frontpen != nullpen) { - draw(f,s.transverse.back,thin+defaultbackpen+backpen,light); - draw(f,s.transverse.front,thin+frontpen,light); + draw(f,t*s.transverse.back,thin+defaultbackpen+backpen,light); + draw(f,t*s.transverse.front,thin+frontpen,light); } if(longitudinalpen != nullpen) { - draw(f,s.longitudinal.back,thin+defaultbackpen+longitudinalbackpen, + draw(f,t*s.longitudinal.back,thin+defaultbackpen+longitudinalbackpen, light); - draw(f,s.longitudinal.front,thin+longitudinalpen,light); + draw(f,t*s.longitudinal.front,thin+longitudinalpen,light); } } |