Solved

degree finding

Posted on 2004-04-27
3
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…

710 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