Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Angle between line and axis
Date: Tue, 10 Jan 2012 16:43:07 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 20
Message-ID: <jehpqr$nmb$1@newscl01ah.mathworks.com>
References: <jehf9c$esc$1@newscl01ah.mathworks.com> <d9d5fbf1-2532-4943-9114-3b12d20e06bb@i6g2000vbk.googlegroups.com> <09d3b079-5702-4fe9-8036-71369a6af095@dp8g2000vbb.googlegroups.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1326213787 24267 172.30.248.47 (10 Jan 2012 16:43:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 10 Jan 2012 16:43:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:754322

Rune Allnor <allnor@tele.ntnu.no> wrote in message <09d3b079-5702-4fe9-8036-71369a6af095@dp8g2000vbb.googlegroups.com>...
> On 10 Jan, 16:37, "Suzana " <suzana.petro...@mfkg.rs> wrote:
> > I hope so that I find the right angle. I try to use this
> >
> > angle=atan2(z2-z1,y2-y1)*180/pi;
> >
> > Am I on the right way with this?
> 
> No. You shouldn't believe everything you
> read on the internet. You might want to
> consult the odd textbook as well.

Wait a minute. 

angle_in_radian=atan2(y2-y1,x2-x1);
angle_in_deg=atan2(y2-y1,x2-x1)*180/pi;

are absolutely correct ways to compute angle between x-axis and P1P2, where P1=(x1,y1) and P1=(x2,y2). It is more accurate than acos(.) (see Roger's many posts on the topic).

Bruno