From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/29168 Path: news.gmane.org!not-for-mail From: "Mojca Miklavec" Newsgroups: gmane.comp.tex.context Subject: Re: Metapost label alignment etc. Date: Thu, 6 Jul 2006 16:39:04 +0200 Message-ID: <6faad9f00607060739w2919210bwa4522df0af2ff5f2@mail.gmail.com> References: <44A59A7B.5040009@wxs.nl> <6faad9f00606301717x2250d314pf6280502263ea468@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1152196777 13862 80.91.229.2 (6 Jul 2006 14:39:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 6 Jul 2006 14:39:37 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Jul 06 16:39:33 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1FyV0j-0007M8-1n for gctc-ntg-context-518@m.gmane.org; Thu, 06 Jul 2006 16:39:21 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id F1C4612788; Thu, 6 Jul 2006 16:39:20 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04564-05; Thu, 6 Jul 2006 16:39:11 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 6FCC6127B4; Thu, 6 Jul 2006 16:39:11 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 1227E127B4 for ; Thu, 6 Jul 2006 16:39:08 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 04562-05 for ; Thu, 6 Jul 2006 16:39:06 +0200 (CEST) Original-Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by ronja.ntg.nl (Postfix) with SMTP id 2C57612788 for ; Thu, 6 Jul 2006 16:39:05 +0200 (CEST) Original-Received: by nf-out-0910.google.com with SMTP id m18so142226nfc for ; Thu, 06 Jul 2006 07:39:05 -0700 (PDT) Original-Received: by 10.78.151.15 with SMTP id y15mr232502hud; Thu, 06 Jul 2006 07:39:04 -0700 (PDT) Original-Received: by 10.78.72.12 with HTTP; Thu, 6 Jul 2006 07:39:04 -0700 (PDT) Original-To: "mailing list for ConTeXt users" In-Reply-To: Content-Disposition: inline X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:29168 Archived-At: On 7/6/06, Idris Samawi Hamid wrote: > Hi, Aditya, > > (I must admit I'm still struggling with mastering Mojca's approach ;-). I guess that I should read this as "please comment your code better next time" > pair diag[]; diag1 = (2,1.25); diag2=(10,-2.5); I used diag1 to define the translation between the front and the back face and diag2 to define the translation between the first and the second cube. for i=0 upto 1: for j=0 upto 1: for k=0 upto 1: for l=0 upto 1: z[i+2j+4k+8l] = (((i,j) scaled a) shifted (diag1 scaled k) shifted (diag2 scaled l)) scaled u; endfor; endfor; endfor; endfor; i is the counter for x axes: i=0 means left, i=1 means the right point j is the counter for y axes: j=0 means bottom, j=2 means the upper point Original point will thus have coordinates (i,j) and we create 4 points (sorry, I'm leaving out the braces): z2---z3 | | z0---z1 k is the counter for z axes: z=0 means the front face, z=1 means the back face The original point(s) are translated for diag1: shifted (diag1 scaled k): if k=0, no translation is present, if k=1 it's translated to the back. You then get additional 4 poins, namely z6---z7 | | z4---z5 traslated for vector diag1 to form the back face. Finally, you use the counter l for the first and the second cube. shifted (diag2 scaled l) doesn't do anything if l=0 ("shifted (diag scaled 0)" is same as "shifted (0,0)" which is identity) and translates the first cube into the second one when l=1. z[...+8l] will number the points from 0 to 7 (depending on i,j,k) when l=1 and from 8 to 15 when l=1, so you get the same points with index of z increased for 8 if you're in the second cube. > for i=0 upto 3: > draw z[4i]--z[4i+1]--z[4i+3]--z[4i+2]--cycle; this will draw: - z0--z1--z3--z2--cycle (first cube, the front face) - z4--z5--z7--z6--cycle (first cube, the front face) - z8--z9--z11--z10--cycle (second cube, the front face) - z12--z13--z15--z14--cycle (second cube, the front face) > % small diagonals > draw z[i]--z[i+4]; > draw z[i+8]--z[i+12]; this will draw z0--z4, z1--z5, z2--z6, z3--z7: "diagonals" connecting the front face with back face and same for the second cube, only for z[index+8] > draw z[i]--z[i+8]; this will connect the fron face of the first cube with the fron face of the second cube (+8) > draw z[i+4]--z[i+12]; same, bu for the back face; this could be done with the first definition already if 'i' went from 0 to 7 instead from 0 to 3. > label (textext("Sans Serif"),.5[z[3],z[4]]) ; z3 is the upper right point in the front face and z4 the lower left point in the back face, .5 is the point in the middle then. > label (textext("Serif"),.5[z[11],z[12]]) ; z11 and z12 are the same points (3+8 and 4+8) on the second cube. Hope that helps, Mojca (Asymptote does some conversions directly since it supports 3D, but I never worked with it, most probably because it's not integrated so well with ConTeXt, although it seems a bit more optimistic in the last time.)