diff options
Diffstat (limited to 'graphics/asymptote/base')
-rw-r--r-- | graphics/asymptote/base/geometry.asy | 27 | ||||
-rw-r--r-- | graphics/asymptote/base/plain.asy | 9 | ||||
-rw-r--r-- | graphics/asymptote/base/plain_strings.asy | 6 |
3 files changed, 28 insertions, 14 deletions
diff --git a/graphics/asymptote/base/geometry.asy b/graphics/asymptote/base/geometry.asy index 306add19fc..adfeb9910e 100644 --- a/graphics/asymptote/base/geometry.asy +++ b/graphics/asymptote/base/geometry.asy @@ -31,6 +31,8 @@ import math; import markers; +real Infinity=1.0/(1000*realEpsilon); + // A rotation in the direction dir limited to [-90,90] // This is useful for rotating text along a line in the direction dir. private transform rotate(explicit pair dir) @@ -724,6 +726,11 @@ real angle(explicit point M, coordsys R = M.coordsys, bool warn = true) return radians(degrees(M, R, warn)); } +bool Finite(explicit point z) +{ + return abs(z.x) < Infinity && abs(z.y) < Infinity; +} + /*<asyxml><function type="bool" signature="finite(explicit point)"><code></asyxml>*/ bool finite(explicit point p) {/*<asyxml></code><documentation>Avoid to compute 'finite((pair)(infinite_point))'.</documentation></function></asyxml>*/ @@ -3275,7 +3282,7 @@ ellipse operator cast(circle c) } /*<asyxml><operator type = "circle" signature="cast(ellipse)"><code></asyxml>*/ -circle operator cast(ellipse el) +circle operator ecast(ellipse el) {/*<asyxml></code><documentation></documentation></operator></asyxml>*/ circle oc; bool infb = (!finite(el.a) || !finite(el.b)); @@ -3287,7 +3294,7 @@ circle operator cast(ellipse el) } /*<asyxml><operator type = "ellipse" signature="cast(conic)"><code></asyxml>*/ -ellipse operator cast(conic co) +ellipse operator ecast(conic co) {/*<asyxml></code><documentation>Cast a conic to an ellipse (can be a circle).</documentation></operator></asyxml>*/ if(degenerate(co) && co.e < 1) return ellipse(co.l[0].A, co.l[0].B, infinity); ellipse oe; @@ -3305,7 +3312,7 @@ ellipse operator cast(conic co) } /*<asyxml><operator type = "parabola" signature="cast(conic)"><code></asyxml>*/ -parabola operator cast(conic co) +parabola operator ecast(conic co) {/*<asyxml></code><documentation>Cast a conic to a parabola.</documentation></operator></asyxml>*/ parabola op; if(abs(co.e - 1) > epsgeo) abort("casting: The conic section is not a parabola."); @@ -3320,7 +3327,7 @@ conic operator cast(parabola p) } /*<asyxml><operator type = "hyperbola" signature="cast(conic)"><code></asyxml>*/ -hyperbola operator cast(conic co) +hyperbola operator ecast(conic co) {/*<asyxml></code><documentation>Cast a conic section to an hyperbola.</documentation></operator></asyxml>*/ hyperbola oh; if(co.e > 1) { @@ -3372,7 +3379,7 @@ conic operator cast(circle c) } /*<asyxml><operator type = "circle" signature="cast(conic)"><code></asyxml>*/ -circle operator cast(conic c) +circle operator ecast(conic c) {/*<asyxml></code><documentation>Conic section to circle.</documentation></operator></asyxml>*/ ellipse el = (ellipse)c; circle oc; @@ -3588,7 +3595,7 @@ bqe equation(parabola p) bqe.a[0] * x^2 + bqe.a[1] * x * y + bqe.a[2] * y^2 + bqe.a[3] * x + bqe.a[4] * y + bqe.a[5] = 0 One can change the coordinate system of 'bqe' using the routine 'changecoordsys'.</documentation></function></asyxml>*/ coordsys R = canonicalcartesiansystem(p); - parabola tp = changecoordsys(R, p); + parabola tp = (parabola) changecoordsys(R, p); point A = projection(tp.D) * point(R, (0, 0)); real a = abs(A); return changecoordsys(coordsys(p), @@ -6488,7 +6495,7 @@ point[] intersectionpoints(line l, ellipse el) coordsys R = samecoordsys(l.A, el.C) ? l.A.coordsys : defaultcoordsys; coordsys Rp = defaultcoordsys; line ll = changecoordsys(Rp, l); - ellipse ell = changecoordsys(Rp, el); + ellipse ell = (ellipse) changecoordsys(Rp, el); circle C = circle(ell.C, ell.a); point[] Ip = intersectionpoints(ll, C); if (Ip.length > 0 && @@ -6562,7 +6569,7 @@ point[] intersectionpoints(line l, hyperbola h) coordsys R = coordsys(h); point A = intersectionpoint(l, h.A1), B = intersectionpoint(l, h.A2); point M = midpoint(segment(A, B)); - bool tgt = M @ h; + bool tgt = Finite(M) ? M @ h : false; if(tgt) { if(M @ l) op.push(M); } else { @@ -6645,7 +6652,7 @@ point[] intersectionpoints(bqe bqe1, bqe bqe2) for(int j=0; j < x.length; ++j) { if(abs(b[0]*x[j]^2+b[1]*x[j]*y[i]+b[2]*y[i]^2+b[3]*x[j] +b[4]*y[i]+b[5]) < 1e-5) - P.push(point(R,(x[j],y[i]))); + P.push(changecoordsys(currentcoordsys,point(R,(x[j],y[i])))); } } return P; @@ -6661,7 +6668,7 @@ point[] intersectionpoints(bqe bqe1, bqe bqe2) for(int j=0; j < y.length; ++j) { if(abs(b[0]*x[i]^2+b[1]*x[i]*y[j]+b[2]*y[j]^2+b[3]*x[i]+b[4]*y[j]+b[5]) < 1e-5) - P.push(point(R,(x[i],y[j]))); + P.push(changecoordsys(currentcoordsys,point(R,(x[i],y[j])))); } } return P; diff --git a/graphics/asymptote/base/plain.asy b/graphics/asymptote/base/plain.asy index 4afe3cb3de..480780c458 100644 --- a/graphics/asymptote/base/plain.asy +++ b/graphics/asymptote/base/plain.asy @@ -193,14 +193,19 @@ string stripsuffix(string f, string suffix=".asy") return f; } +string outdirectory() +{ + return stripfile(outprefix()); +} + // Conditionally process each file name in array s in a new environment. void asy(string format, bool overwrite=false ... string[] s) { for(string f : s) { f=stripsuffix(f); string suffix="."+format; - string fsuffix=f+suffix; - if(overwrite || error(input(fsuffix,check=false))) { + string fsuffix=stripdirectory(f+suffix); + if(overwrite || error(input(outdirectory()+fsuffix,check=false))) { string outformat=settings.outformat; bool interactiveView=settings.interactiveView; bool batchView=settings.batchView; diff --git a/graphics/asymptote/base/plain_strings.asy b/graphics/asymptote/base/plain_strings.asy index c109fc491f..8d1fd41bd0 100644 --- a/graphics/asymptote/base/plain_strings.asy +++ b/graphics/asymptote/base/plain_strings.asy @@ -184,16 +184,18 @@ string jobname(string name) string graphic(string name, string options="") { + if(settings.xasy) + name=stripdirectory(name); + if(latex()) { if(options != "") options="["+options+"]"; - bool pdf=pdf(); string includegraphics="\includegraphics"+options; if(settings.inlinetex) return includegraphics+"{"+jobname(name)+"}"; else return includegraphics+ (find(name," ") < 0 ? "{"+name+"}" : - (pdf ? "{\""+stripextension(name)+"\".pdf}" : "{\""+name+"\"}")); + (pdf() ? "{\""+stripextension(name)+"\".pdf}" : "{\""+name+"\"}")); } if(settings.tex != "context") notimplemented("graphic"); |