From: Rune Allnor <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: perpendicular line -- follow up
Date: Tue, 31 May 2011 21:57:52 -0700 (PDT)
Lines: 25
Message-ID: <>
References: <is3fg5$25i$> <is40r2$ikd$>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1306904272 22330 (1 Jun 2011 04:57:52 GMT)
NNTP-Posting-Date: Wed, 1 Jun 2011 04:57:52 +0000 (UTC)
Injection-Info:; posting-host=; posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLEUHCNK
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
 2.0.50727; InfoPath.2; MS-RTC LM 8; .NET CLR 1.1.4322),gzip(gfe)
Xref: comp.soft-sys.matlab:729610

On Jun 1, 5:26 am, "Lisa " <> wrote:
> Roger,
> i am sorry but when i take your solution to matlab, it does not plot two orthogonal lines but two separate ones. maybe i should clarify my problem a little bit more: i am plotting patch objects (rectangles) that span the distance from one point to another. these two points may lie anywhere in the 2D space. my actual problem is that the rectangle between them is never perfectly rectangular but always a little bit skewed so that not all of its angles have 90 degrees. this i would like to avoid by plotting the perpendicular lines.

That's a different task than the question you asked.
If you have two points, p1 = [x1 y1] and p2 = [x2,y2],
you need to do something like

P00 = [min(x1,x2),min(y1,y2)];
P10 = [max(x1,x2),min(y1,y2)];
P11 = [max(x1,x2),max(y1,y2)];
P01 = [min(x1,x2),max(y1,y2)];

patch([P00(1) P10(1) P11(1) P01(1)],[P00(2) P10(2) P11(2) P01(2)],