Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into msvc-support-make
Browse files Browse the repository at this point in the history
  • Loading branch information
jamievlin committed Aug 15, 2024
2 parents 1b8712e + a058c4b commit 35e076e
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 50 deletions.
2 changes: 1 addition & 1 deletion asymptote.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%global __python %{__python3}

Name: asymptote
Version: 2.912.91
Version: 2.91
Release: 1%{?dist}
Summary: Descriptive vector graphics language

Expand Down
22 changes: 12 additions & 10 deletions base/graph3.asy
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,10 @@ void zaxis3At(picture pic=currentpicture, Label L="", axis axis,
}

// Internal routine to autoscale the user limits of a picture.
void autoscale3(picture pic=currentpicture, axis axis,
projection P=currentprojection)
void autoscale3(picture pic=currentpicture, axis axis)
{
bool set=pic.scale.set;
autoscale(pic,axis);
P.recenter(pic.userMin3(),pic.userMax3());

if(!set) {
bounds mz;
Expand Down Expand Up @@ -964,7 +962,7 @@ void xaxis3(picture pic=currentpicture, Label L="", axis axis=YZZero,

if(!pic.scale.set) {
axis(pic,axis);
autoscale3(pic,axis,P);
autoscale3(pic,axis);
}

bool newticks=false;
Expand Down Expand Up @@ -1011,6 +1009,7 @@ void xaxis3(picture pic=currentpicture, Label L="", axis axis=YZZero,

bool back=false;
if(axis.type == Both) {
projection P=centered(P,pic);
triple v=P.normal;
back=dot((0,pic.userMax().y-pic.userMin().y,0),v)*sgn(v.z) > 0;
}
Expand Down Expand Up @@ -1039,7 +1038,7 @@ void yaxis3(picture pic=currentpicture, Label L="", axis axis=XZZero,

if(!pic.scale.set) {
axis(pic,axis);
autoscale3(pic,axis,P);
autoscale3(pic,axis);
}

bool newticks=false;
Expand Down Expand Up @@ -1087,6 +1086,7 @@ void yaxis3(picture pic=currentpicture, Label L="", axis axis=XZZero,

bool back=false;
if(axis.type == Both) {
projection P=centered(P,pic);
triple v=P.normal;
back=dot((pic.userMax().x-pic.userMin().x,0,0),v)*sgn(v.z) > 0;
}
Expand Down Expand Up @@ -1115,7 +1115,7 @@ void zaxis3(picture pic=currentpicture, Label L="", axis axis=XYZero,

if(!pic.scale.set) {
axis(pic,axis);
autoscale3(pic,axis,P);
autoscale3(pic,axis);
}

bool newticks=false;
Expand Down Expand Up @@ -1162,6 +1162,7 @@ void zaxis3(picture pic=currentpicture, Label L="", axis axis=XYZero,

bool back=false;
if(axis.type == Both) {
projection P=centered(P,pic);
triple v=P.vector();
back=dot((pic.userMax().x-pic.userMin().x,0,0),v)*sgn(v.y) > 0;
}
Expand Down Expand Up @@ -1212,11 +1213,12 @@ void axes3(picture pic=currentpicture,
bool extend=false,
triple min=(-infinity,-infinity,-infinity),
triple max=(infinity,infinity,infinity),
pen p=currentpen, arrowbar3 arrow=None, margin3 margin=NoMargin3)
pen p=currentpen, arrowbar3 arrow=None, margin3 margin=NoMargin3,
projection P=currentprojection)
{
xaxis3(pic,xlabel,YZZero(extend),min.x,max.x,p,arrow,margin);
yaxis3(pic,ylabel,XZZero(extend),min.y,max.y,p,arrow,margin);
zaxis3(pic,zlabel,XYZero(extend),min.z,max.z,p,arrow,margin);
xaxis3(pic,xlabel,YZZero(extend),min.x,max.x,p,arrow,margin,P);
yaxis3(pic,ylabel,XZZero(extend),min.y,max.y,p,arrow,margin,P);
zaxis3(pic,zlabel,XYZero(extend),min.z,max.z,p,arrow,margin,P);
}

triple Scale(picture pic=currentpicture, triple v)
Expand Down
5 changes: 3 additions & 2 deletions base/grid3.asy
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ void grid3(picture pic=currentpicture,
grid3routines gridroutinej=gridroutine[j];
for(int i=0; i < gridroutinej.length; ++i) {
grid3 gt=gridroutinej[i](pic);
pic.add(new void(picture f, transform3 t, transform3 T, triple, triple) {
pic.add(new void(picture f, transform3 t, transform3 T,
projection P, triple, triple) {
picture d;
ticks3 ticks=Ticks3(1,F="%",ticklabel=null,
beginlabel=false,endlabel=false,
Expand All @@ -202,7 +203,7 @@ void grid3(picture pic=currentpicture,
Size=0,size=0,extend=true,
pTick=pGrid,ptick=pgrid);
ticks(d,t,"",gt.axea,gt.axeb,nullpen,None,NoMargin3,gt.locate,
gt.bds.divisor,opposite=true,primary=false);
gt.bds.divisor,opposite=true,primary=false,P);
add(f,t*T*inverse(t)*d);
},above=above);
addPath(pic,gt.axea,pGrid);
Expand Down
24 changes: 22 additions & 2 deletions base/plain_picture.asy
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,12 @@ struct picture { // <<<1
},exact,above);
}

void add(void d(picture, transform3, transform3, projection P=currentprojection, triple, triple),
void add(void d(picture, transform3, transform3, projection, triple, triple),
bool exact=false, bool above=true) {
add(new void(frame f, transform3 t, transform3 T, picture pic2,
projection P, triple lb, triple rt) {
picture opic=new picture;
d(opic,t,T,lb,rt);
d(opic,t,T,P,lb,rt);
add(f,opic.fit3(identity4,pic2,P));
},exact,above);
}
Expand Down Expand Up @@ -1134,6 +1134,26 @@ pair size(picture pic, bool user=false)
return t*M-t*m;
}

// Return a projection adjusted to view center of pic from specified direction.
projection centered(projection P, picture pic=currentpicture) {
projection P=P.copy();
if(P.autoadjust && P.center) {
triple min=pic.userMin3();
triple max=pic.userMax3();
if(min != max) {
triple target=0.5*(max+min);
if(pic.keepAspect)
P.camera=target+P.vector();
else
P.camera=target+realmult(unit(P.vector()),max-min);
P.target=target;
P.normal=P.vector();
P.calculate();
}
}
return P;
}

// Frame Alignment <<<
pair rectify(pair dir)
{
Expand Down
12 changes: 0 additions & 12 deletions base/plain_prethree.asy
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ struct projection {
bool center=false; // Center target within bounding volume?
int ninterpolate; // Used for projecting nurbs to 2D Bezier curves.
bool bboxonly=true; // Typeset label bounding box only.
triple vector0; // Specified camera-target vector

transformation T;

Expand All @@ -91,15 +90,6 @@ struct projection {
return camera-target;
}

void recenter(triple min, triple max) {
if(center) {
target=0.5*(max+min);
camera=target+realmult(unit(vector0),max-min);
normal=vector();
calculate();
}
}

void operator init(triple camera, triple up=(0,0,1), triple target=(0,0,0),
triple normal=camera-target,
real zoom=1, real angle=0, pair viewportshift=0,
Expand All @@ -116,7 +106,6 @@ struct projection {
this.autoadjust=autoadjust;
this.center=center;
this.projector=projector;
this.vector0=vector();
calculate();
}

Expand All @@ -138,7 +127,6 @@ struct projection {
P.projector=projector;
P.ninterpolate=ninterpolate;
P.bboxonly=bboxonly;
P.vector0=vector0;
P.T=T.copy();
return P;
}
Expand Down
6 changes: 2 additions & 4 deletions base/plain_shipout.asy
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ void shipout(string prefix=defaultfilename, picture pic=currentpicture,
string options="", string script="",
light light=currentlight, projection P=currentprojection)
{
projection P=P.copy();
// Automatically adjust camera to view target from specified direction.
if(P.autoadjust && !pic.keepAspect)
P.recenter(pic.userMin3(),pic.userMax3());
projection P=centered(P,pic);

if(!uptodate()) {
bool inlinetex=settings.inlinetex;
bool prc=prc(format) || settings.v3d;
Expand Down
10 changes: 2 additions & 8 deletions base/three.asy
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct render

bool closed; // use one-sided PRC rendering?

bool tessellate; // use tessellated mesh to store straight patches?
bool tessellate; // use tessellated mesh to store straight patches

bool3 merge; // merge PRC nodes before rendering, for faster but
// lower quality rendering (the value default means
Expand All @@ -60,7 +60,7 @@ struct render
int sphere; // PRC sphere type (PRCsphere or NURBSsphere).

// General parameters:
real margin; // shrink amount for rendered openGL viewport, in bp.
real margin; // shrink amount for rendered OpenGL viewport, in bp.
bool partnames; // assign part name indices to compound objects
bool defaultnames; // assign default names to unnamed objects
interaction interaction; // billboard interaction mode
Expand Down Expand Up @@ -293,7 +293,6 @@ projection operator * (transform3 t, projection P)
P.normal=t*(target+P.normal)-P.target;
else
P.normal=P.vector();
P.vector0=t*P.vector0;
P.calculate();
}
return P;
Expand Down Expand Up @@ -2694,11 +2693,6 @@ struct scene
this.P=t*this.P;
if(this.P.autoadjust || this.P.infinity)
adjusted=adjusted | this.P.adjust(m,M);
if(this.P.center && settings.render != 0) {
triple target=0.5*(m+M);
this.P.target=target;
this.P.calculate();
}
}

bool scale=xsize != 0 || ysize != 0;
Expand Down
22 changes: 20 additions & 2 deletions doc/asymptote.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8207,6 +8207,21 @@ other formats. One can request a completely transparent background for
3D @code{WebGL} images with
@code{currentlight.background=black+opacity(0.0);}

@code{render}

A function @code{render()} may be assigned to the optional
@code{render} parameter allows one to pass specialized rendering
options to the surface drawing routines, via arguments such as:
@verbatim
bool tessellate; // use tessellated mesh to store straight patches
real margin; // shrink amount for rendered OpenGL viewport, in bp.
bool partnames; // assign part name indices to compound objects
bool defaultnames; // assign default names to unnamed objects
interaction interaction; // billboard interaction mode
@end verbatim
along with the rendering parameters for the legacy PRC format
described in @code{three.asy}.

@cindex image-based lighting
@cindex @code{surface}
@cindex @code{ibl}
Expand Down Expand Up @@ -9110,7 +9125,9 @@ To draw an @math{x} axis in three dimensions, use the routine
@verbatim
void xaxis3(picture pic=currentpicture, Label L="", axis axis=YZZero,
real xmin=-infinity, real xmax=infinity, pen p=currentpen,
ticks3 ticks=NoTicks3, arrowbar3 arrow=None, bool above=false);
ticks3 ticks=NoTicks3, arrowbar3 arrow=None,
margin3 margin=NoMargin3, bool above=false,
projection P=currentprojection);
@end verbatim
@noindent
Analogous routines @code{yaxis} and @code{zaxis} can be used to draw
Expand All @@ -9122,7 +9139,8 @@ void axes3(picture pic=currentpicture,
bool extend=false,
triple min=(-infinity,-infinity,-infinity),
triple max=(infinity,infinity,infinity),
pen p=currentpen, arrowbar3 arrow=None);
pen p=currentpen, arrowbar3 arrow=None,
margin3 margin=NoMargin3, projection P=currentprojection);
@end verbatim

@cindex @code{YZEquals}
Expand Down
2 changes: 1 addition & 1 deletion doc/axis3.asy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import graph3;
size(0,200);
size3(200,IgnoreAspect);

currentprojection=perspective(5,2,2);
currentprojection=perspective(dir(75,20));

scale(Linear,Linear,Log);

Expand Down
2 changes: 1 addition & 1 deletion examples/AiryDisk.asy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import graph3;
import gsl;

size(10cm,15cm,IgnoreAspect);
currentprojection=orthographic(150,50,1);
currentprojection=orthographic(dir(70,60));

real f(pair z) {real r=abs(z); return r == 0 ? 1 : (2.0*J(1,r)/r)^2;}

Expand Down
2 changes: 1 addition & 1 deletion examples/RiemannSurface.asy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import palette;
size(200,300,keepAspect=false);
//settings.nothin=true;

currentprojection=orthographic(10,10,30);
currentprojection=orthographic(dir(70,60));
currentlight=(10,10,5);
triple f(pair t) {return (exp(t.x)*cos(t.y),exp(t.x)*sin(t.y),t.y);}

Expand Down
2 changes: 1 addition & 1 deletion examples/RiemannSurfaceRoot.asy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int n=3;

size(200,300,keepAspect=false);

currentprojection=orthographic(10,10,30);
currentprojection=orthographic(dir(60,60));
currentlight=(10,10,5);
triple f(pair t) {return (t.x*cos(t.y),t.x*sin(t.y),t.x^(1/n)*sin(t.y/n));}

Expand Down
3 changes: 1 addition & 2 deletions examples/extrudedcontour.asy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import graph3;

defaultrender.merge=true;

currentprojection=orthographic(25,10,10);
currentprojection=orthographic(dir(60,25));
size(0,12cm);
real a=3;
real b=4;
Expand All @@ -22,4 +22,3 @@ surface s=surface(f,(0,0),(10,10),20,Spline);
s.colors(palette(s.map(zpart),Rainbow()+opacity(0.5)));
draw(s);
axes3("$x$","$y$","$z$",Arrow3);

2 changes: 1 addition & 1 deletion examples/gamma3.asy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import graph3;
import palette;

size(12cm,IgnoreAspect);
currentprojection=orthographic(1,-2,1);
currentprojection=orthographic(dir(80,290));

real X=4.5;
real M=abs(gamma((X,0)));
Expand Down
3 changes: 2 additions & 1 deletion examples/projectelevation.asy
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import graph3;
import grid3;
import palette;

currentprojection=orthographic(0.8,1,2);
size(400,300,IgnoreAspect);

currentprojection=orthographic(dir(50,50));

real f(pair z) {return cos(2*pi*z.x)*sin(2*pi*z.y);}

surface s=surface(f,(-1/2,-1/2),(1/2,1/2),50,Spline);
Expand Down
2 changes: 1 addition & 1 deletion examples/smoothelevation.asy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ currentlight=Viewport;

if(settings.render <= 0) settings.prc=false;

currentprojection=orthographic(1,2,13);
currentprojection=orthographic(dir(40,60));

size(400,300,IgnoreAspect);

Expand Down

0 comments on commit 35e076e

Please sign in to comment.