From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67326 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Stefan_M=FCller?= Newsgroups: gmane.comp.tex.context Subject: Re: Metfun macro for triangle Date: Thu, 24 Mar 2011 11:29:53 +0100 Message-ID: <4D8B1D21.7020906@gmx.de> References: <33B6C5DE-9240-4A26-9AE9-F0C362769AB2@gmail.com> <4D8B0EE1.2050506@gmx.de> <00DC3FB2-8584-4D72-9DA3-12319B000906@gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1300962625 11385 80.91.229.12 (24 Mar 2011 10:30:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 10:30:25 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 11:30:20 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2ho4-0004Eq-9e for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 11:30:20 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6DB2FCAB42; Thu, 24 Mar 2011 11:30:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iNiGnnF7T4Av; Thu, 24 Mar 2011 11:30:02 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DCAAECAB21; Thu, 24 Mar 2011 11:30:02 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 97B17CAB21 for ; Thu, 24 Mar 2011 11:30:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ewC6RuMxGGqZ for ; Thu, 24 Mar 2011 11:29:50 +0100 (CET) Original-Received: from filter3-nij.mf.surf.net (filter3-nij.mf.surf.net [195.169.124.154]) by balder.ntg.nl (Postfix) with ESMTP id 3E12FCAAFF for ; Thu, 24 Mar 2011 11:29:50 +0100 (CET) Original-Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.23]) by filter3-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with SMTP id p2OAU1iJ015375 for ; Thu, 24 Mar 2011 11:30:01 +0100 Original-Received: (qmail invoked by alias); 24 Mar 2011 10:30:00 -0000 Original-Received: from 77-64-138-214.dynamic.primacom.net (EHLO [192.168.100.108]) [77.64.138.214] by mail.gmx.net (mp053) with SMTP; 24 Mar 2011 11:30:00 +0100 X-Authenticated: #11064435 X-Provags-ID: V01U2FsdGVkX19RFNNAJyVR4G3c/SivhbhRI1UUd1Hks8DhpbiCRs fCyGdOjRln/PDI User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <00DC3FB2-8584-4D72-9DA3-12319B000906@gmail.com> X-Y-GMX-Trusted: 0 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.165.64.23; country=DE; latitude=51.0000; longitude=9.0000; http://maps.google.com/maps?q=51.0000,9.0000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0dEmWu1Kc - ff9b8382289a - 20110324 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.154 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:67326 Archived-At: On 24.03.2011 10:57, Otared Kavian wrote: > Hi Stefan, > > Thanks for the quick answer and solution! > Your solution works perfectly in mkiv; however typesetting with mkii resu= lts in > ! Undefined control sequence. > l.3 \startMPdefinitions > Is there a solution with mkii? Then just drop the MPdefinitions section and put the complete vardef = before your normal mp code in the MPcode section. That should work, I think. > May I ask one more question? > In the macro you wrote > Triangle((0cm,0cm), (5cm,0cm), 8cm, 6cm) > one has to specify the double of the length of each side (because a unit = circle in MetaPost is a circle having diameter one). Would it be possible t= o change slightly the lines Now that's strange... But I see what you mean. I didn't notice. > p :=3D fullcircle scaled la shifted za ; > q :=3D fullcircle scaled lb shifted zb ; > so that la and lb are replaced with their doubled values? I tried > p :=3D fullcircle scaled 2*la shifted za ; Yeah, you need parentheses here, because otherwise Metapost tries to = scale by 2 and then doesn't know how to multiply the result (the path = "fullcircle scaled 2") with "la". p :=3D fullcircle scaled (2 * la) shifted za ; q :=3D fullcircle scaled (2 * lb) shifted zb ; > but this does not work. > > Thanks for your attention: OK np, Stefan. > On 24 mars 2011, at 10:29, Stefan M=FCller wrote: > >> Hi, >> >> what about >> >> \startMPdefinitions >> vardef Triangle(expr za, zb, la, lb) =3D >> path p, q ; >> pair zc ; >> pickup pencircle scaled 2mm ; >> drawdot za ; >> drawdot zb ; >> p :=3D fullcircle scaled la shifted za ; >> q :=3D fullcircle scaled lb shifted zb ; >> zc =3D p intersectionpoint q ; >> drawdot zc ; >> pickup pencircle scaled 1mm ; >> za--zb--zc--cycle >> enddef; >> \stopMPdefinitions >> >> \starttext >> \startMPcode >> draw Triangle((0cm,0cm), (5cm,0cm), 8cm, 6cm) withcolor blue ; = >> \stopMPcode >> \stoptext >> >> Stefan >> >> On 24.03.2011 09:59, Otared Kavian wrote: >>> Hi all, >>> >>> I have a document in which I must draw several triangles for which two = summits, say z0, z1, and the length of the two other sides are known, so th= at the third summit, say z2, is completly determined. >>> In order to draw one triangle the following works fine: >>> >>> \setupcolors[state=3Dstart] >>> \starttext >>> \startMPcode >>> z0 =3D (0cm,0cm) ; >>> z1 =3D (5cm,0cm) ; >>> path p, q ; = >>> pickup pencircle scaled 2mm ; >>> drawdot z0 ; >>> drawdot z1 ; >>> p :=3D halfcircle scaled 8 cm ; % twice the length of the second side = at z0 >>> p :=3D p shifted z0 ; >>> q :=3D halfcircle scaled 6 cm ; % twice the length of the second side= at z1 >>> q :=3D q shifted z1 ; >>> z2 =3D p intersectionpoint q ; >>> drawdot z2 ; >>> pickup pencircle scaled 1mm ; >>> draw z0--z1--z2--cycle withcolor blue ; >>> \stopMPcode >>> \stoptext >>> >>> However I would like to have a macro, for instance named Triangle, whic= h accepts four arguments z0,z1, length_1, length_2, so that in a MetaPost c= ode i can use >>> draw Triangle(z0,z1, 4, 3) withcolor blue ; >>> in order to draw the above triangle. >>> Has anyone any idea about how to do this? >>> >>> Thanks in advance for your help: OK >>> _______________________________________________________________________= ____________ >>> 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://tex.aanhet.net >>> archive : http://foundry.supelec.fr/projects/contextrev/ >>> wiki : http://contextgarden.net >>> _______________________________________________________________________= ____________ >>> >> ________________________________________________________________________= ___________ >> If your question is of interest to others as well, please add an entry t= o the Wiki! >> >> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-c= ontext >> webpage : http://www.pragma-ade.nl / http://tex.aanhet.net >> archive : http://foundry.supelec.fr/projects/contextrev/ >> wiki : http://contextgarden.net >> ________________________________________________________________________= ___________ > > %%%%%%%%%%%%%%%%%% > Otared Kavian > D=E9partement de Math=E9matiques > Universit=E9 de Versailles Saint-Quentin > B=E2timent Fermat > 45 avenue des Etats Unis > 78035 Versailles cedex > > T=E9l=E9phone: +33 1 39 25 46 42 > Secr=E9tariat: +33 1 39 25 46 44 > Secr=E9tariat: +33 1 39 25 46 46 > > e-mail: Otared.Kavian@math.uvsq.fr > > > > > _________________________________________________________________________= __________ > 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-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ > ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________