Solved

degree finding

Posted on 2004-04-27
3
151 Views
Last Modified: 2010-04-17
how can i find the degree of two lines if i am given the two lines connected with each other ,their coordinations also given?
pls give me the logic
0
Comment
Question by:Jenith
3 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 125 total points
ID: 10936100
0
 
LVL 22

Expert Comment

by:NovaDenizen
ID: 10938628
There are two lines: one from (x1,y1) to (x2,y2) and one from (x3,y3) to (x4,y4)

dx1 = x2 - x1
dy1 = y2 - y1
dx2 = x4 - x3
dy2 = y4 - y3

mag1 = sqrt(dx1*dx1 + dy1 * dy1)    ; magnitude of first segment
mag2 = sqrt(dx2*dx2 + dy2 * dy2)     ; magnitude of second segment
dp = (dx1 * dx2 + dy1 * dy2) / (mag1 * mag2)     ; dot product of two difference vectors, normalized
; now, dp = cosine(angle) = sin(PI/2 - angle).  
comp = arcsin(dp)  ; which == PI/2 - angle
angle = PI/2 - comp

angle is now the angle between the two lines, in terms of radians
angle_deg = angle * 180 / PI

I
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question