Solved

degree finding

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 62
copyEndy  challenge 15 55
find a node in VST 2 46
Not needed 13 54
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now