ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: James Fisher <jameshfisher@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: METAPOST -- specifying an unknown point coordinate by giving the angle from another known point
Date: Fri, 26 Feb 2010 01:18:57 +0000	[thread overview]
Message-ID: <771da05a1002251718l55669a0co770b5a78bed84e4b@mail.gmail.com> (raw)

This isn't specifically a ConTeXt question, but via it I've run into a
seemingly simple problem in METAPOST that I just can't solve.  I'm
trying to draw a parallelogram by specifying: (1) the length of sides
parallel to the x-axis; (2) the total height of the figure; (3) one of
the interior angles.  This is how I'm trying to solve it:

-----------------

% Draw a parallelogram, like so:
%
%         z3    z2
%         +-----+   ^
%        /     /    |
%       /     /     |
%      /     /      |10 units
%     /BL   /       |
%    +-----+        v
%   z0     z1
%    <----->
%    5 units
%
%    Interior angle BL = 87 degrees


beginfig(1);

  z0 = origin;        % bottom left
  z1 = (5,0);         % bottom right
  y2 = y3 = 10;       % shape is 10 units high
  x2 - x3 = x1 - x0;  % top edge is the same length as bottom edge

  % We've completely specified z0 and z1;
  % We know that the top edge is the same length and angle as the
bottom, but lies somewhere on y = 10;
  % all we have to do is specify one angle and we have a complete parallelogram.
  %
  % The following should work as it provides the following information:
  % the unit vector from z0 to z3 is at an angle 87 degrees
anticlockwise from (0,0) -- (1,0).

  angle(z3-z0) = dir(87);

endfig;
end;

--------------------

This doesn't work; using the angle() function gives the error:

   Not implemented: angle(unknown pair).

Strictly speaking, yes, z3 has an unknown x-coordinate at that time in
execution.  But I am told that METAPOST is declarative, so I would
expect my line of code to mean: "set the x-coordinate of z3 such that
angle(z3-z0) = dir(87)".  AFAICS that provides all the needed
information to draw the shape.

So, is there another way I can do what I want without falling into
low-level trig?



Best,


James
___________________________________________________________________________________
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
___________________________________________________________________________________


             reply	other threads:[~2010-02-26  1:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-26  1:18 James Fisher [this message]
2010-02-26  1:41 ` Troy Henderson
2010-02-26  1:44   ` Troy Henderson
2010-02-26  2:14     ` James Fisher
2010-02-26  3:29       ` Troy Henderson
2010-02-26 21:42 ` Nicola
2010-02-28  0:37   ` James Fisher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=771da05a1002251718l55669a0co770b5a78bed84e4b@mail.gmail.com \
    --to=jameshfisher@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).