From 4c0e3e7fa86ecd3794204d362c7e17b3d9433415 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 16 Jan 2020 03:01:19 +0000 Subject: CTAN sync 202001160301 --- graphics/asymptote/base/geometry.asy | 41 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'graphics/asymptote/base/geometry.asy') diff --git a/graphics/asymptote/base/geometry.asy b/graphics/asymptote/base/geometry.asy index adfeb9910e..1c8a95063f 100644 --- a/graphics/asymptote/base/geometry.asy +++ b/graphics/asymptote/base/geometry.asy @@ -22,7 +22,7 @@ // An Asymptote geometry module. // THANKS: -// Special thanks to Olivier Guibé for his help in mathematical issues. +// Special thanks to Olivier Guibe for his help in mathematical issues. // BUGS: @@ -759,7 +759,7 @@ real dot(explicit pair A, point B) transform rotateO(real a) {/*Rotation around the origin of the current coordinate system.*/ return rotate(a, currentcoordsys.O); -}; +} /**/ transform projection(point A, point B) @@ -1502,7 +1502,7 @@ struct segment {/*.*/ restricted point A, B;// Extremity. restricted vector u, v;// u = direction vector, v = normal vector. - restricted real a, b, c;// Coefficients of the équation ax + by + c = 0 + restricted real a, b, c;// Coefficients of the equation ax + by + c = 0 restricted real slope, origin; segment copy() { @@ -2548,17 +2548,18 @@ struct ellipse /**/ restricted point F1,F2,C;/*Foci and center.*/ restricted real a,b,c,e,p;/**/ - restricted real angle;/*Value is degrees(F1 - F2).*/ + restricted real angle;/*Value is degrees(F2 - F1).*/ restricted line D1,D2;/*Directrices.*/ line l;/*If one axis is infinite, this line is used instead of ellipse.*/ + /**/ void init(point f1, point f2, real a) - {/*Ellipse given by foci and semimajor axis*/ + {/*Ellipse given by foci and semimajor axis.*/ point[] P = standardizecoordsys(f1, f2); this.F1 = P[0]; this.F2 = P[1]; - this.angle = abs(P[1]-P[0]) < 10 * epsgeo ? 0 : degrees(P[1]-P[0]); this.C = (P[0] + P[1])/2; + this.angle = degrees(F2 - F1, warn=false); this.a = a; if(!finite(a)) { this.l = line(P[0], P[1]); @@ -2582,7 +2583,7 @@ struct ellipse bool degenerate(ellipse el) { - return (!finite(el.a) || !finite(el.b)); + return !finite(el.a) || !finite(el.b); } /**/ @@ -2590,7 +2591,7 @@ struct parabola {/*Look at http://mathworld.wolfram.com/Parabola.html*/ restricted point F,V;/*Focus and vertex*/ restricted real a,p,e = 1;/**/ - restricted real angle;/*Angle, in degrees, of the line (FV).*/ + restricted real angle;/*Value is degrees(F - V).*/ restricted line D;/*Directrix*/ pair bmin, bmax;/*The (left, bottom) and (right, top) coordinates of region bounding box for drawing the parabola. If unset the current picture bounding box is used instead.*/ @@ -2599,13 +2600,13 @@ struct parabola void init(point F, line directrix) {/*Parabola given by focus and directrix.*/ point[] P = standardizecoordsys(F, directrix.A, directrix.B); - line l = line(P[1], P[2]); this.F = P[0]; + line l = line(P[1], P[2]); this.D = l; this.a = distance(P[0], l)/2; this.p = 2 * a; this.V = 0.5 * (F + projection(D) * P[0]); - this.angle = degrees(F - V); + this.angle = degrees(F - V, warn=false); } }/**/ @@ -2615,7 +2616,7 @@ struct hyperbola restricted point F1,F2;/*Foci.*/ restricted point C,V1,V2;/*Center and vertices.*/ restricted real a,b,c,e,p;/**/ - restricted real angle;/*Angle,in degrees,of the line (F1F2).*/ + restricted real angle;/*Value is degrees(F2 - F1).*/ restricted line D1,D2,A1,A2;/*Directrices and asymptotes.*/ pair bmin, bmax; /*The (left, bottom) and (right, top) coordinates of region bounding box for drawing the hyperbola. If unset the current picture bounding box is used instead.*/ @@ -2626,9 +2627,9 @@ struct hyperbola point[] P = standardizecoordsys(f1, f2); this.F1 = P[0]; this.F2 = P[1]; - this.angle = degrees(F2 - F1); - this.a = a; this.C = (P[0] + P[1])/2; + this.angle = degrees(F2 - F1, warn=false); + this.a = a; this.c = abs(C - P[0]); this.e = this.c/a; if(this.e <= 1) abort("hyperbola.init: wrong parameter: e <= 1."); @@ -2889,7 +2890,6 @@ hyperbola hyperbola(point P1, point P2, real ae, bool byfoci = byfoci) /**/ ellipse ellipse(point F1, point F2, point M) {/*Return the ellipse passing through 'M' whose the foci are 'F1' and 'F2'.*/ - point P[] = standardizecoordsys(false, F1, F2, M); real a = abs(F1 - M) + abs(F2 - M); return ellipse(F1, F2, finite(a) ? a/2 : a); } @@ -3091,6 +3091,13 @@ parabola parabola(point M1, point M2, point M3, point M4, point M5) return parabola(bqe(M1, M2, M3, M4, M5)); } +/**/ +hyperbola hyperbola(point F1, point F2, point M) +{/*Return the hyperbola passing through 'M' whose the foci are 'F1' and 'F2'.*/ + real a = abs(abs(F1 - M) - abs(F2 - M)); + return hyperbola(F1, F2, finite(a) ? a/2 : a); +} + /**/ hyperbola hyperbola(point C, real a, real b, real angle = 0) {/*Return the hyperbola centered at 'C' with semimajor axis 'a' along C--C + dir(angle), @@ -6502,7 +6509,7 @@ point[] intersectionpoints(line l, ellipse el) (perpendicular(ll, line(ell.F1, Ip[0])) || perpendicular(ll, line(ell.F2, Ip[0])))) { // http://www.mathcurve.com/courbes2d/ellipse/ellipse.shtml - // Définition tangentielle par antipodaire de cercle. + // Definition of the tangent at the antipodal point on the circle. // 'l' is a tangent of 'el' transform t = scale(el.a/el.b, el.F1, el.F2, el.C, rotate(90, el.C) * el.F1); point inter = inverse(t) * intersectionpoints(C, t * ll)[0]; @@ -6672,7 +6679,7 @@ point[] intersectionpoints(bqe bqe1, bqe bqe2) } } return P; -}; +} /**/ point[] intersectionpoints(conic co1, conic co2) @@ -7047,7 +7054,7 @@ arc arccircle(point A, point M, point B) real m = degrees(M - tc.C); arc oa = arc(tc, a, b); - // TODO : use cross product to determine CWW or CW + // TODO: use cross product to determine CWW or CW if (!(M @ oa)) { oa.direction = !oa.direction; } -- cgit v1.2.3