Solved

degree finding

Posted on 2004-04-27
3
150 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Report events not being triggered 8 120
groupSum6 challenge 6 86
python question 5 76
C# application error "Parameter Is Not Valid". 3 94
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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