vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

inradius() does not working as expected #415

Closed ElegantSimplicity closed 6 months ago

ElegantSimplicity commented 6 months ago

From geometry.asy, for calculating inradius of a triangle, I found that inradius() does not working as expected.

// http://asymptote.ualberta.ca/
import geometry;
unitsize(1cm);

pair A = (0,0), B=(5,0), C = (1,3.5);

pair J = incenter(A,B,C);  // correct
pair r = inradius(A,B,C);  // incorrect 
real rr = abs(J-reflect(A,B)*J)/2;  // correct but not convernient

draw(circle(J,rr),red);
draw(circle(J,r),blue);

draw(A--B--C--cycle);

label("$A$", A, SW);
label("$B$", B, SE);
label("$C$", C, N);
dot("$J$", J, red);
justonlyasy commented 6 months ago

The function inradius() is a real type, not pair. Take a look at the geometry.asy file, line 5439, abs(IC - projection(A, B) * IC) is similar to abs(J-reflect(A,B)*J)/2.

ElegantSimplicity commented 6 months ago

@justonlyasy oh, I have spent time with my naive mistake. Thank you!