From: David Arnold <darnold@northcoast.com>
Subject: Re: Clipping a path to a boundary --- Being more specific
Date: Wed, 10 Aug 2005 09:15:31 -0700 [thread overview]
Message-ID: <F945E446-09B9-11DA-A50F-001124338712@northcoast.com> (raw)
In-Reply-To: <1E73D8F9-0935-11DA-A154-001124338712@northcoast.com>
Hans et al,
I think I've found something that works. I know ahead of time that
there will only be two crossings of the clipping path boundary (I make
sure of the by the parameters I choose):
beginfig(0);
% initialize a, h, and h for f(x)=ax^2+bx+c=a(x-h)^2+k
numeric a, h, k;
a=-1;
h=-3;
k=2;
% initialize scale
numeric u; 10u=3in;
% draw grid
for k=-5u step 1u until 5u:
draw (-5u,k)--(5u,k) withcolor 0.85white;
draw (k,-5u)--(k,5u) withcolor 0.85white;
endfor;
% draw axes
drawarrow (-5u,0)--(5u,0);
drawarrow (0,-5u)--(0,5u);
% label axes
label.rt(btex $x$ etex, (5.2u,0));
label.top(btex $y$ etex, (0,5.2.u));
label.bot(btex $5$ etex, (5u,0));
label.lft(btex $5$ etex, (0,5u));
% define function f(x)=a|x-b|+c
vardef f(expr x)=
a*(x-h)*(x-h)+k
enddef;
% draw line with given point and slope
path F;
F:=(-6,f(-6));
for x=-6 step .1 until 6:
F:=F--(x,f(x));
endfor;
% the line
F:=F scaled 1u;
% clipping path
path cpath;
cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle;
cpath:=cpath scaled 1u;
% clip the path F
pair A, B;
F:=F cutbefore cpath;
F:=reverse F;
F:=F cutbefore cpath;
drawdblarrow F;
endfig;
end.
prev parent reply other threads:[~2005-08-10 16:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-08 1:17 David Arnold
2005-08-08 13:20 ` Hans Hagen
2005-08-10 0:24 ` David Arnold
2005-08-10 16:15 ` David Arnold [this message]
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=F945E446-09B9-11DA-A50F-001124338712@northcoast.com \
--to=darnold@northcoast.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).