From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/109654 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fabrice L Newsgroups: gmane.comp.tex.context Subject: Re: Units of xpart and ypart of a pair in MetaFun Date: Thu, 26 Nov 2020 10:19:48 -0500 Message-ID: <380BF9A6-1F98-44AB-BB27-5ACB3F8061A3@gmail.com> References: <68dba0aa-8cc8-0a93-29bf-81afc7bf9079@gmail.com> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Content-Type: multipart/mixed; boundary="===============4127001675675322508==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18924"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mckaymeister@gmail.com To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Nov 26 16:20:18 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 1kiJ4E-0004ok-R2 for gctc-ntg-context-518@m.gmane-mx.org; Thu, 26 Nov 2020 16:20:18 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2B1F51AA694; Thu, 26 Nov 2020 16:19:58 +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 pRD74fI46sTT; Thu, 26 Nov 2020 16:19:55 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0C4FA1AA696; Thu, 26 Nov 2020 16:19:55 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id DB90E1AA691 for ; Thu, 26 Nov 2020 16:19: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 L-YtQPSPxiGc for ; Thu, 26 Nov 2020 16:19:53 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.160.176; helo=mail-qt1-f176.google.com; envelope-from=fabrice.alpha@gmail.com; receiver= Original-Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 D39D81AA68D for ; Thu, 26 Nov 2020 16:19:52 +0100 (CET) Original-Received: by mail-qt1-f176.google.com with SMTP id f15so1295942qto.13 for ; Thu, 26 Nov 2020 07:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=FD1LTG66XGjhOVVrJAm8pAj325TBQgDaNININC06wP8=; b=SoazTMfWlExxE+MKunW4DWER6wne+8Egkqfo9tZURAbvi0uQBI+ycyMkJhUe2Phhdf atFoPSbxfo/9GSeMYqsUoKhT76749RN0/DPqp4dkesM+ZvbKmKzAI5Z7TK4B1D4kMP/d TijbQasZO10LAB/kg8cXAA8XB5E6Djc9RBR/NLWSBogdzd0QKBOHWSlpv1QXX+9+NSnO P3Tz1SNJCEaDmebNskYBeYYTtwh5o+QNvoOLRjYku8VhPpQuEKv/vCzH2ka0AbxdKSWd ywBuvpIRQ4eaQzwF4Gisq9yvbvMRdzhcaYF0i01CluyqpW/CIQZJ/55yuKQgFw5Tl3d4 JFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=FD1LTG66XGjhOVVrJAm8pAj325TBQgDaNININC06wP8=; b=LwyLaHo4DDrPhKGPdfIuX0Hy8fMxK7A9ZyRnrS+rnFwcdSGOGsVPPZm/c+xe8VlbAc Yfp5Mw/NNLuJ6s4FbcxFxYFkvZsSYyBIeoBeksNFPF6oJPWy8pINd/9t7AUAvhPcan73 avAsV/eP42bLUdDS+ijSW3jzwRuhhdKcBbpKvtaib4d37Y3ftpuTidyBwXv1skGChKuo rTmoCc6xxUnoa4C+mAcYE7OHx1qXl6944rpLNtL7VRbaBEZc5XAOZpNNbAaTekj7nplJ H/tzEeOWp6+YgFfi3zZjSs3LPrQWjTYoYuJPmAcJ+RgFlW94DtbfFuTKVry6RW4Chp6/ 487A== X-Gm-Message-State: AOAM532fzvHcwHEbKgnDhhk4Skq4rWNiHoMsYJnA/4JndiM+FNZStuRo +qhh+3NICGgZsM2s2HOr255qV+SAdig= X-Google-Smtp-Source: ABdhPJzSamghd3UIefTRwCE2WKdK5DSD838D0SF+mAMsXTy5lep2S3cxlL8c7dn466J91Hy4/+71zQ== X-Received: by 2002:ac8:5c95:: with SMTP id r21mr3621424qta.152.1606403990979; Thu, 26 Nov 2020 07:19:50 -0800 (PST) Original-Received: from icovid.lan ([38.74.28.141]) by smtp.gmail.com with ESMTPSA id n125sm2804793qkd.85.2020.11.26.07.19.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2020 07:19:49 -0800 (PST) In-Reply-To: <68dba0aa-8cc8-0a93-29bf-81afc7bf9079@gmail.com> X-Mailer: Apple Mail (2.3654.20.0.2.21) 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:109654 Archived-At: --===============4127001675675322508== Content-Type: multipart/alternative; boundary="Apple-Mail=_FC573245-CA81-4CD3-84BD-2629F5976800" --Apple-Mail=_FC573245-CA81-4CD3-84BD-2629F5976800 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi keith, > Le 26 nov. 2020 =C3=A0 10:09, Keith McKay a = =C3=A9crit : >=20 > Hi, >=20 > 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: >=20 > pair (2cm, 11cm) to give xpart 2 and ypart 11 >=20 > However I was getting: >=20 > pair (2cm, 11cm) -> xpart 56.6929 and ypart 311.8096 >=20 > 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? >=20 > The MWE belows shows what I have been doing. >=20 > Thanks >=20 > Keith McKay >=20 > %%% MWE %%% > \setuppapersize [A5, landscape][A4, portrait] > \usecolors[crayola] > \starttext > \startMPpage > StartPage; > width :=3D PaperWidth ; height :=3D PaperHeight ; unit :=3D cm ; > numeric squig; > pair a[]; a0 =3D (2cm,11cm); a1 =3D (4cm,10cm); a2 =3D (6cm,9cm); = a3 =3D (8cm,8cm); > show xpart a[0], ypart a[0]; %Example of result from x and ypart = before applying correction factor (cf) % > cf :=3D 72/2.54; %Converts points/in to points/cm% > path pp; > for i =3D 0 step 1 until 3: > pp :=3D ((xpart a[i])/cf*cm, (ypart a[i])/cf*cm); > for squig =3D 1 step 1 until 15: > xcoord :=3D uniformdeviate(1) - 0.5 + (xpart a[i]/cf); > ycoord :=3D uniformdeviate(1) - 0.5+ (ypart a[i]/cf); > pp :=3D pp .. {curl 100}(xcoord*cm, ycoord*cm); > endfor; > pp :=3D pp --- cycle; > if i < 3 : > pp :=3D pp --- ((xpart a[i+1]/cf)*cm, (ypart = a[i+1])/cf*cm); > fi;=09 > f :=3D((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 > %%%%%%%%%%%%%% >=20 MetaPost (MetaFun) is taking care of everything regarding units. As you = ave discovered, everything is translated to a unique internal dimension. = So you can write: a :=3D (1cm,2in) ; with no problem. The =C2=AB cm =C2=BB and =C2=AB in =C2=BB parts of the = expression will become numbers to translate this number on the right = unit.=20 Fabrice. > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ >=20 --Apple-Mail=_FC573245-CA81-4CD3-84BD-2629F5976800 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hi = keith,

Le 26 nov. 2020 =C3=A0 10:09, Keith McKay = <mckaymeister@gmail.com> a =C3=A9crit :

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 :=3D = PaperWidth ; height :=3D PaperHeight ; unit :=3D cm ;
numeric squig;
pair a[]; a0 =3D (2cm,11cm); a1 =3D = (4cm,10cm); a2 =3D (6cm,9cm); a3 =3D (8cm,8cm);
show xpart a[0], ypart a[0]; %Example of = result from x and ypart before applying correction factor (cf) = %
cf :=3D 72/2.54; %Converts points/in = to points/cm%
path pp;
for i =3D 0 step 1 until 3:
pp :=3D ((xpart a[i])/cf*cm, (ypart = a[i])/cf*cm);
for squig =3D 1 = step 1 until 15:
xcoord = :=3D uniformdeviate(1) - 0.5 + (xpart a[i]/cf);
ycoord :=3D uniformdeviate(1) - = 0.5+ (ypart a[i]/cf);
pp :=3D = pp .. {curl 100}(xcoord*cm, ycoord*cm);
= endfor;
pp :=3D pp --- = cycle;
if i < 3 = :
pp :=3D pp --- ((xpart = a[i+1]/cf)*cm, (ypart a[i+1])/cf*cm);
= fi;
f :=3D((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
%%%%%%%%%%%%%%


MetaPost (MetaFun) is = taking care of everything regarding units. As you ave discovered, = everything is translated to a unique internal dimension. So you can = write:

 a :=3D (1cm,2in) = ;

with no problem. The = =C2=AB cm =C2=BB and =C2=AB in =C2=BB parts of the = expression will become numbers to translate this number on the right = unit. 
Fabrice.

_______________________________________________________________= ____________________
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
_______________________________________________________________= ____________________


= --Apple-Mail=_FC573245-CA81-4CD3-84BD-2629F5976800-- --===============4127001675675322508== 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== --===============4127001675675322508==--