Skip to content

Commit

Permalink
Fix Bezier patch bounds bug introduced in bf3be19.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncbowman committed Apr 13, 2020
1 parent 7f9480e commit 3542857
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 31 deletions.
2 changes: 1 addition & 1 deletion doc/asymptote.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ current locale;

@item string time(string format="%a %b %d %T %Z %Y")
@cindex @code{time}
@cindex @code{date}
@cindex date
@cindex @code{strftime}
returns the current time formatted by the ANSI C routine
@code{strftime} according to the string @code{format} using the current
Expand Down
8 changes: 4 additions & 4 deletions drawsurface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ void drawBezierPatch::bounds(const double* t, bbox3& b)
double cz[16];

if(t == NULL) {
for(int i=0; i < 16; ++i) {
for(unsigned int i=0; i < 16; ++i) {
triple v=controls[i];
cx[i]=v.getx();
cy[i]=v.gety();
cz[i]=v.getz();
}
} else {
for(int i=0; i < 16; ++i) {
for(unsigned int i=0; i < 16; ++i) {
triple v=t*controls[i];
cx[i]=v.getx();
cy[i]=v.gety();
Expand All @@ -127,7 +127,7 @@ void drawBezierPatch::bounds(const double* t, bbox3& b)
c0=cy[0];
fuzz=Fuzz*run::norm(cy,16);
y=bound(cy,min,b.empty ? c0 : min(c0,b.bottom),fuzz,maxdepth);
Y=boundtri(cy,max,b.empty ? c0 : max(c0,b.top),fuzz,maxdepth);
Y=bound(cy,max,b.empty ? c0 : max(c0,b.top),fuzz,maxdepth);

c0=cz[0];
fuzz=Fuzz*run::norm(cz,16);
Expand Down Expand Up @@ -359,7 +359,7 @@ void drawBezierTriangle::bounds(const double* t, bbox3& b)
cz[i]=v.getz();
}
}

double c0=cx[0];
double fuzz=Fuzz*run::norm(cx,10);
x=boundtri(cx,min,b.empty ? c0 : min(c0,b.left),fuzz,maxdepth);
Expand Down
41 changes: 15 additions & 26 deletions examples/unitoctant.asy
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
import graph3;

currentprojection=orthographic(5,4,2);
currentprojection=orthographic(5,5,8);

size(0,150);
patch s=octant1x;
draw(surface(s),green+opacity(0.5));
draw(s.external(),blue);
patch s0=octant1.s[0];
patch s1=octant1.s[1];
draw(surface(s0),green+opacity(0.5));
draw(surface(s1),green+opacity(0.5));
draw(s0.external(),blue);
draw(s1.external(),blue);

triple[][] P=s.P;
triple[][] P0=s0.P;
triple[][] P1=s1.P;

for(int i=0; i < 4; ++i)
dot(P[i],red);
dot(P0[i],red+0.75mm);

for(int i=0; i < 4; ++i)
dot(P1[i],red+0.65mm);

axes3("$x$","$y$",Label("$z$",align=Z));
triple P00=P[0][0];
triple P10=P[1][0];
triple P01=P[0][1];
triple P02=P[0][2];
triple P11=P[1][1];
triple P12=P[1][2];
triple Q11=XYplane(xypart(P11));
triple Q12=XYplane(xypart(P12));

draw(P11--Q11,dashed);
draw(P12--Q12,dashed);
draw(O--Q12--Q11--(Q11.x,0,0));
draw(Q12--(Q12.x,0,0));

label("$(1,0,0)$",P00,-2Y);
label("$(1,a,0)$",P10,-Z);
label("$(1,0,a)$",P01,-2Y);
label("$(a,0,1)$",P02,Z+X-Y);
label("$(1,a,a)$",P11,3X);
label("$(a,a^2,1)$",P12,7X+Y);


35 changes: 35 additions & 0 deletions examples/unitoctantx.asy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import graph3;

currentprojection=orthographic(5,4,2);

size(0,150);
patch s=octant1x;
draw(surface(s),green+opacity(0.5));
draw(s.external(),blue);

triple[][] P=s.P;

for(int i=0; i < 4; ++i)
dot(P[i],red);

axes3("$x$","$y$",Label("$z$",align=Z));
triple P00=P[0][0];
triple P10=P[1][0];
triple P01=P[0][1];
triple P02=P[0][2];
triple P11=P[1][1];
triple P12=P[1][2];
triple Q11=XYplane(xypart(P11));
triple Q12=XYplane(xypart(P12));

draw(P11--Q11,dashed);
draw(P12--Q12,dashed);
draw(O--Q12--Q11--(Q11.x,0,0));
draw(Q12--(Q12.x,0,0));

label("$(1,0,0)$",P00,-2Y);
label("$(1,a,0)$",P10,-Z);
label("$(1,0,a)$",P01,-2Y);
label("$(a,0,1)$",P02,Z+X-Y);
label("$(1,a,a)$",P11,3X);
label("$(a,a^2,1)$",P12,7X+Y);

0 comments on commit 3542857

Please sign in to comment.