> On 26 Nov 2020, at 16:09, Keith McKay <mckaymeister@gmail.com> wrote:
>
> Hi,
>
> I have been using xpart and ypart to extract these values from pairs of points in a path but I wasn't getting the correct result. I was expecting:
>
> pair (2cm, 11cm) to give xpart 2 and ypart 11
As explained by various people, Metapost does not have dimensions. All lengths are implicit Postscript big points
(72/inch). Variables like “cm” just add a multiplication factor to your expressions, at no point is a dimension stored inside Metapost.
Your equation:
a0 = (2cm,11cm)
first expands into
a0 = (2*28.34645,11*28.34645)
because “cm” is a variable with a value (Its definition in plain.mp is "cm = 28.34645”)
Then, the two expressions in the a0 equation are resolved before the assignment, so what you actually wrote at the statement level is
a0 = (56.6929, 311.8096);
At no point is there a “cm”-sized dimension.
===
Perhaps another option would be for you to do all your work without units, e.g.
a0 = (2,11) % assume scaling will happen later
and then in the end do the drawing on a scaled path:
draw (pp scaled cm) …
as that may be less confusing? If the precision is an issue, you could counter the loss of precision you could use implied millimeters instead of centimeters.
Best wishes,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________