From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/109653 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Keith McKay Newsgroups: gmane.comp.tex.context Subject: Units of xpart and ypart of a pair in MetaFun Date: Thu, 26 Nov 2020 15:09:47 +0000 Organization: The PotHole Press Message-ID: <68dba0aa-8cc8-0a93-29bf-81afc7bf9079@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2070357719049813350==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13665"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.4.2 To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Nov 26 16:10:13 2020 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kiIuS-0003Rk-Hl for gctc-ntg-context-518@m.gmane-mx.org; Thu, 26 Nov 2020 16:10:12 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0E6AD1AA68F; Thu, 26 Nov 2020 16:09:53 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R474exMImEg0; Thu, 26 Nov 2020 16:09:52 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0AB401AA693; Thu, 26 Nov 2020 16:09:52 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CE1461AA690 for ; Thu, 26 Nov 2020 16:09:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id leBZEBr-w42w for ; Thu, 26 Nov 2020 16:09:50 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.41; helo=mail-wr1-f41.google.com; envelope-from=mckaymeister@gmail.com; receiver= Original-Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 3C56D1AA68F for ; Thu, 26 Nov 2020 16:09:50 +0100 (CET) Original-Received: by mail-wr1-f41.google.com with SMTP id i2so2485830wrs.4 for ; Thu, 26 Nov 2020 07:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:organization:message-id:date:user-agent :mime-version:content-language; bh=JWBAIQ0jgT98j5qg0fq6VM1TENSBlvimRw0PoQTRaw0=; b=bl+LDaMebhUdKePDTx3A+GcKp7imO7vgPMY68ZyH2TAmJrSdMac+lxcJ0xWKdF0hRc b1ayemealJP2K6f/Xpo2ZEgcUwpgmqWqWxOA/TbEe8fGScfJ12P+a61s5Q8TJYu5CLCg 9MIoKI3RjvgDJrlfYiPm1CQcItJ0MXObX8Y3OagopmNbK3RIGIU626DUgNQ/aLw1ZQXy 5dLg2Ux55o1VtMsnczhMKPPqqujoh/DTHn2ai+pwtYjcaR/YFxGiZ/wO19ZpGMOPfB2r MpKyNFHI/lj1HyPxiC0+aaa9a3bIhnV7FvLNx9ktB8eVcue6h/1F96BMK4/7x6E9YJrH 39dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:organization:message-id:date :user-agent:mime-version:content-language; bh=JWBAIQ0jgT98j5qg0fq6VM1TENSBlvimRw0PoQTRaw0=; b=H75QHUHpfPMIV8aDuB9KdSltvVL+GUNHEVB66/mVuQCcjfkZjQhCfBS93+nN7VTLEB qxZGItrbLkCfMh9ktAeqgwaQPM9qGf4MqbEO3IpH28lRX33lEQtPTl6wJp+qMjGCbuF6 KUbmP+Wfgs3HmtxkMZxHsyUX5+TX8/qSJKUz2YjaxLEfYvd/jKcVzqO9/QfYo9gIGA8Y /51tyX9tzKQBW2kamNW4oPes5K9Wmiq4yQw0xXDleJk21iI9JUiAbYoJA5C9v+KV1huK j5oL3w059sZU3GGGMnQmow7z+rmYDEUna7KUy8GFaZENbL4FvzawII6WYTx5+tkgbgF5 h/ZQ== X-Gm-Message-State: AOAM5333TmTNYRTMmh0OhkEbbobrnGcRtHsZmsACUgxZhqRRoXVLC7S1 ob31a/2FhG46VxetS6jx7fZWytZpd0k= X-Google-Smtp-Source: ABdhPJzC16smxE0csLxM/j7QuAZq58NeTDsGR5fNLmEr5A9gOO8xc3tawlVARpEgqlzk+zTrGoeWqA== X-Received: by 2002:a5d:634d:: with SMTP id b13mr4546285wrw.310.1606403389453; Thu, 26 Nov 2020 07:09:49 -0800 (PST) Original-Received: from Keiths-Mac-mini.local (cpc100594-uddi29-2-0-cust51.20-3.cable.virginm.net. [82.42.107.52]) by smtp.googlemail.com with ESMTPSA id f23sm8701027wml.14.2020.11.26.07.09.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Nov 2020 07:09:48 -0800 (PST) Content-Language: en-US X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:109653 Archived-At: This is a multi-part message in MIME format. --===============2070357719049813350== Content-Type: multipart/alternative; boundary="------------06B91669F4BA7E2375AA29E5" Content-Language: en-US This is a multi-part message in MIME format. --------------06B91669F4BA7E2375AA29E5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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 However I was getting: pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096 After much head scratching and reading the MetaPost and MetaFun manuals, I realised that the units of xpart or ypart are in Postcript points or Big Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of xpart or ypart in cm I would have to use a correction factor. I had made the assumption that since the x and ypart in the pair was in cm that the result would be in cm, but I see now that this is not the case. Will I have to continue doing this or is there some magic within MetaFun which takes account of the units in a pair and outputs the result of x and ypart in the same units? The MWE belows shows what I have been doing. Thanks Keith McKay %%% MWE %%% \setuppapersize [A5, landscape][A4, portrait] \usecolors[crayola] \starttext \startMPpage StartPage; width := PaperWidth ; height := PaperHeight ; unit := cm ; numeric squig; pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = (8cm,8cm); show xpart a[0], ypart a[0]; %Example of result from x and ypart before applying correction factor (cf) % cf := 72/2.54; %Converts points/in to points/cm% path pp; for i = 0 step 1 until 3: pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); for squig = 1 step 1 until 15: xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf); ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf); pp := pp .. {curl 100}(xcoord*cm, ycoord*cm); endfor; pp := pp --- cycle; if i < 3 : pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm); fi; f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken colour % draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 withcolor (f[white,\MPcolor{BurntSienna}]); endfor; StopPage; \stopMPpage \stoptext %%%%%%%%%%%%%% --------------06B91669F4BA7E2375AA29E5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

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

However I was getting:

pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096

After much head scratching and reading the MetaPost and MetaFun manuals, I realised that the units of xpart or ypart are in Postcript points or Big Points (bp), and 1 bp is 1/72 of an inch, and thus to get the values of xpart or ypart in cm I would have to use a correction factor. I had made the assumption that since the x and ypart in the pair was in cm that the result would be in cm, but I see now that this is not the case. Will I have to continue doing this or is there some magic within MetaFun which takes account of the units in a pair and outputs the result of x and ypart in the same units?

The MWE belows shows what I have been doing.

Thanks

Keith McKay

%%% MWE %%%

\setuppapersize [A5, landscape][A4, portrait]

\usecolors[crayola]

\starttext

\startMPpage

StartPage;

width := PaperWidth ; height := PaperHeight ; unit := cm ;

numeric squig;

pair a[]; a0 = (2cm,11cm); a1 = (4cm,10cm); a2 = (6cm,9cm); a3 = (8cm,8cm);

show xpart a[0], ypart a[0]; %Example of result from x and ypart before applying correction factor (cf) %

cf := 72/2.54; %Converts points/in to points/cm%

path pp;

for i = 0 step 1 until 3:

pp := ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm);

for squig = 1 step 1 until 15:

xcoord := uniformdeviate(1) - 0.5 + (xpart a[i]/cf);

ycoord := uniformdeviate(1) - 0.5+ (ypart a[i]/cf);

pp := pp .. {curl 100}(xcoord*cm, ycoord*cm);

endfor;

pp := pp --- cycle;

if i < 3 :

pp := pp --- ((xpart a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);

fi;

f :=((1.4 - 0.6) * uniformdeviate(1)) + 0.8; % Factor to lighten/darken colour %

draw pp withpen pencircle xscaled 0.5mm yscaled .1mm rotated 45 withcolor (f[white,\MPcolor{BurntSienna}]);

endfor;

StopPage;

\stopMPpage

\stoptext

%%%%%%%%%%%%%%

--------------06B91669F4BA7E2375AA29E5-- --===============2070357719049813350== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2070357719049813350==--