Am 25.11.2025 um 13:05 schrieb Mason, Roger via ntg-context:
Hello,

This code:

\startMPcode
   u = 2cm; % unit length;
   xmax = 1.5 ; ymax = 1.5 ; % axes parameters
   path circle; circle = fullcircle scaled 2u; draw circle withcolor blue;
   x = -1.0 ; % any value between -1 and 1
   len = 3u; % tangent length
   t = (acos x)/45 ; % point-node of fullcircle corresponding to x
   pair I; I = point t of circle ;
   if (x <> 0.0) and (abs(x) <> 1.0): draw origin -- I ; fi ;
   % tangent on the upper part of circle
   pair v ; v = unitvector I rotated 90 ;
   draw I - 0.5len*v -- I + 0.5len*v  withcolor red ;
   draw I withpen pencircle scaled 3bp;
   drawarrow (-xmax*u, 0) -- (xmax*u, 0) ; % horizontal axis
   drawarrow (0, -ymax*u) -- (0, ymax*u) ; % vertical axis
   label.bot(btex $x$ etex, (xmax*u, 0)) ;
\stopMPcode

Should draw a circle with a tangent at x = -1 parallel to y.  However, the point of tangency is shown at approximately x = 1, y = 0.01 or so. I got the code from a metapost example:

u = 2cm; % unit length;
xmax = 1.5 ; ymax = 1.5 ; % axes parameters
beginfig(1);
   path circle; circle = fullcircle scaled 2u; draw circle withcolor blue ;
   x = -1.0 ; % any value between -1 and 1
   len = 3u; % tangent length
   t = (acos x)/45 ; % point-node of fullcircle corresponding to x
   pair I; I = point t of circle ;
   if (x <> 0) and (abs(x) <> 1): draw origin -- I ; fi ;
   % tangent on the upper part of circle
   pair v ; v = unitvector I rotated 90 ;
   draw I - 0.5len*v -- I + 0.5len*v  withcolor red ;
   draw I withpen pencircle scaled 3bp;
   drawarrow (-xmax*u, 0) -- (xmax*u, 0) ; % horizontal axis
   drawarrow (0, -ymax*u) -- (0, ymax*u) ; % vertical axis
   label.bot(btex $x$ etex, (xmax*u, 0)) ;
endfig;
end;

The original code generates the expected output when run using:

  mpost --mem=metafun --numbersystem="double" tangent.mp

The result of acos is different in LMTX and MkIV.

\starttext
\startMPcode
label(acos(-1),origin);
\stopMPcode
\stoptext

LMTX: 3.1415926535897931
MkIV: 180

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to