From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67334 Path: news.gmane.org!not-for-mail From: Otared Kavian Newsgroups: gmane.comp.tex.context Subject: Re: Metfun macro for triangle Date: Thu, 24 Mar 2011 14:16:16 +0100 Message-ID: <5308C0F7-0C1E-41EE-A624-100002F159A2@gmail.com> References: <33B6C5DE-9240-4A26-9AE9-F0C362769AB2@gmail.com> <4D8B0EE1.2050506@gmx.de> <00DC3FB2-8584-4D72-9DA3-12319B000906@gmail.com> <4D8B1D21.7020906@gmx.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/mixed; boundary="===============1442747526==" X-Trace: dough.gmane.org 1300973130 8988 80.91.229.12 (24 Mar 2011 13:25:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 13:25:30 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 14:25:26 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 1Q2kXU-0008TW-Ks for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 14:25:24 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5502ACAB42; Thu, 24 Mar 2011 14:25:09 +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 Z3H7I5rf91ff; Thu, 24 Mar 2011 14:25:06 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id ECE94CAB2F; Thu, 24 Mar 2011 14:25:05 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 568A2CAB2F for ; Thu, 24 Mar 2011 14:25:04 +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 xo00JbsMkMhV for ; Thu, 24 Mar 2011 14:25:01 +0100 (CET) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by balder.ntg.nl (Postfix) with ESMTP id 633FACAAFF for ; Thu, 24 Mar 2011 14:25:01 +0100 (CET) Original-Received: from mail-wy0-f169.google.com (mail-wy0-f169.google.com [74.125.82.169]) by filter4-til.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2ODPB3I018580 for ; Thu, 24 Mar 2011 14:25:13 +0100 Original-Received: by wyf19 with SMTP id 19so11234795wyf.14 for ; Thu, 24 Mar 2011 06:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:mime-version:content-type:subject:date :in-reply-to:to:references:message-id:x-mailer; bh=OHqlS0kjYnz5a9EdVeDwcEhIKnoSFYnmS/qHyl4hMjI=; b=s9Jun/0BiebQscb2Ussf7MqiltnulHrCOW/HN9FMqvuKR91pyl8Gd1QaBKWQE56dMR jIo8VwX//1xjoiNUVk36p6BTysffit0nHSsaslArNbQ4t47G7G+ncIEck2dEj2895daK GTVTrD/p38yPd7+c2pviDdVh+rBwiqPhCD1TM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer; b=Mt+JfxTM0cI9H+gKoZHx+ibZSEWxmNWRgS5An/5+6j6mYccwqrLi5ydEO4453rmgS2 AF+bpWicwb/i5lIMd9wueqlnn2epSS1022CzGtnHE87CLF4GGJOcCZ9MdI5uY/N1rmCy NpCYgGQuQNUJspzmq2Aa8WssRePsXqfKNBYJg= Original-Received: by 10.216.240.71 with SMTP id d49mr710364wer.0.1300973110925; Thu, 24 Mar 2011 06:25:10 -0700 (PDT) Original-Received: from [192.168.0.10] (mna75-3-82-66-231-76.fbx.proxad.net [82.66.231.76]) by mx.google.com with ESMTPS id g32sm3736330wej.27.2011.03.24.06.25.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2011 06:25:08 -0700 (PDT) In-Reply-To: <4D8B1D21.7020906@gmx.de> X-Mailer: Apple Mail (2.1084) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=74.125.82.169; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 05En1pbJL - 29a110e1da54 - 20110324 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.220 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:67334 Archived-At: --===============1442747526== Content-Type: multipart/alternative; boundary=Apple-Mail-4-542829678 --Apple-Mail-4-542829678 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Hi Stefan, Thanks for your explanations: everything works as expected and your = solution is very instructive for me. Later this weekend I'll put it on the wiki. Have a nice day. Best regards: OK On 24 mars 2011, at 11:29, Stefan M=FCller wrote: >=20 >=20 > On 24.03.2011 10:57, Otared Kavian wrote: >> Hi Stefan, >>=20 >> Thanks for the quick answer and solution! >> Your solution works perfectly in mkiv; however typesetting with mkii = results in >> ! Undefined control sequence. >> l.3 \startMPdefinitions >> Is there a solution with mkii? >=20 > 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. >=20 >> 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 to change slightly the lines >=20 > Now that's strange... But I see what you mean. I didn't notice. >=20 >> 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 ; >=20 > 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". >=20 > p :=3D fullcircle scaled (2 * la) shifted za ; > q :=3D fullcircle scaled (2 * lb) shifted zb ; >=20 >=20 >> but this does not work. >>=20 >> Thanks for your attention: OK >=20 > np, Stefan. >=20 >> On 24 mars 2011, at 10:29, Stefan M=FCller wrote: >>=20 >>> Hi, >>>=20 >>> what about >>>=20 >>> \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 >>>=20 >>> \starttext >>> \startMPcode >>> draw Triangle((0cm,0cm), (5cm,0cm), 8cm, 6cm) withcolor blue ;=09= >>> \stopMPcode >>> \stoptext >>>=20 >>> Stefan >>>=20 >>> On 24.03.2011 09:59, Otared Kavian wrote: >>>> Hi all, >>>>=20 >>>> 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 that the third summit, say z2, is completly determined. >>>> In order to draw one triangle the following works fine: >>>>=20 >>>> \setupcolors[state=3Dstart] >>>> \starttext >>>> \startMPcode >>>> z0 =3D (0cm,0cm) ; >>>> z1 =3D (5cm,0cm) ; >>>> path p, q ;=09 >>>> 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 >>>>=20 >>>> However I would like to have a macro, for instance named Triangle, = which accepts four arguments z0,z1, length_1, length_2, so that in a = MetaPost code 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? >>>>=20 >>>> Thanks in advance for your help: OK >>>> = __________________________________________________________________________= _________ >>>> 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://tex.aanhet.net >>>> archive : http://foundry.supelec.fr/projects/contextrev/ >>>> wiki : http://contextgarden.net >>>> = __________________________________________________________________________= _________ >>>>=20 >>> = __________________________________________________________________________= _________ >>> 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://tex.aanhet.net >>> archive : http://foundry.supelec.fr/projects/contextrev/ >>> wiki : http://contextgarden.net >>> = __________________________________________________________________________= _________ >>=20 >> %%%%%%%%%%%%%%%%%% >> Otared Kavian >> D=E9partement de Math=E9matiques >> Universit=E9 de Versailles Saint-Quentin >> B=E2timent Fermat >> 45 avenue des Etats Unis >> 78035 Versailles cedex >>=20 >> 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 >>=20 >> e-mail: Otared.Kavian@math.uvsq.fr >>=20 >>=20 >>=20 >>=20 >> = __________________________________________________________________________= _________ >> 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://tex.aanhet.net >> archive : http://foundry.supelec.fr/projects/contextrev/ >> wiki : http://contextgarden.net >> = __________________________________________________________________________= _________ >>=20 > = __________________________________________________________________________= _________ > 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://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=20 Secr=E9tariat: +33 1 39 25 46 46 e-mail: Otared.Kavian@math.uvsq.fr --Apple-Mail-4-542829678 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1 Hi = Stefan,

Thanks for your explanations: everything = works as expected and your solution is very instructive for = me.
Later this weekend I'll put it on the = wiki.

Have a nice day.
Best regards: = OK

On 24 mars 2011, at 11:29, Stefan M=FCller = wrote:



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 results = 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 to 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 that 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, which accepts = four arguments z0,z1, length_1, length_2, so that in a MetaPost code 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
<= /blockquote>
archive  : http://foundry.sup= elec.fr/projects/contextrev/
wiki     : http://contextgarden.net
____________________________________________________________= _______________________

____________________________________________________________= _______________________
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
<= /blockquote>
archive =  : http://foundry.sup= elec.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<= br>




____________________________________________________________= _______________________
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
<= blockquote type=3D"cite">archive  : http://foundry.sup= elec.fr/projects/contextrev/
wiki     : http://contextgarden.net
____________________________________________________________= _______________________

___________________________________________= ________________________________________
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.sup= elec.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




= --Apple-Mail-4-542829678-- --===============1442747526== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1442747526==--