[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Caculate the angle between two intersecting lines

Posted on 2014-04-21
10
Medium Priority
?
388 Views
Last Modified: 2014-04-21
Code Example of how would I calculate the angle of two intersecting lines.
Example:
If I have a V shaped object and one line is .75 and the other line is .50 what is the angle between the two lines.

Thanks in advance for your assistance.
0
Comment
Question by:PhilChapmanJr
[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
  • 2
  • 2
  • +2
10 Comments
 
LVL 19

Expert Comment

by:Ken Butters
ID: 40012982
What do you mean one line is .75 and the other is .50

Are you talking about the slope of the line?
0
 
LVL 2

Author Comment

by:PhilChapmanJr
ID: 40013137
If the two lines of the V is 75 and the distance between the two non joined lines if 50 what is the angle?
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 40013173
I assume you mean that the length of the two legs of the V are 75, and the distance between the ends of the V (where the legs are not touching) is 50.

You simply need trigonometry.

What you have is the legs of the V form a hypotenuse, and distance between the open ends of the V is a double set of "Opposites".
(See http://www.mathsisfun.com/sine-cosine-tangent.html or simply google sin, cos, tan or trigonometric functions).

In this case, sin = opposite / hypotenuse.  Your 'opposite' would be 1/2 of the 50, and your hypotenuse would be the legs of the V.

From there, you just need to use the trigonometric functions in the math library of what ever computer language you might be using.  Specifically you need the inverse sin function (many call that asin).

Angle = asin( 75 / 25 )  '25 being 1/2 of 50

The library is likely to give you the answer in radians (where 3.14 radians = 180 degrees).
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 19

Accepted Solution

by:
Ken Butters earned 2000 total points
ID: 40013194
I don't have VB6... I wrote this in VBA... which should be pretty close.

NOTE: From what I researched about VB6 neither the ASIN function nor a PI funciton exist, so you have to supply your own.

Public Const Pi As Double = 3.14159265358979
Sub test()

    Dim side As Long
    Dim base As Long
    Dim hyp As Long
    Dim opp As Long
    Dim angle As Double
    
    
    side = 75
    base = 50
    
    hyp = side
    opp = base / 2
    
' multiplying by 2 because we were solving for half the original triangle.
' multiplying by 180 / PI to convert radians to to degrees

    angle = arcSin(opp / hyp) * 180 / Pi * 2
    

End Sub

' arc sine
' error if value is outside the range [-1,1]

Function arcSin(value As Double) As Double
    If Abs(value) <> 1 Then
        arcSin = Atn(value / Sqr(1 - value * value))
    Else
        arcSin = 1.5707963267949 * Sgn(value)
    End If
    
End Function

Open in new window

0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 40013199
Follow-up

VB6 doesn't have a built-in Arc-sine function.  It only has:
sine ( sin() )
cosine ( cos() )
tangent ( tan() )
ArcTangent ( Atn() )

But you can use math to calculate an ArcSine():
Arcsin(X) = Atn(X / Sqr(-X * X+1))

Again, that formula is going to give you an answer in radians.  If you need it in degrees, multiply by 180 and divide by 3.14159265359
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40013217
You need to give one more fact, you need 3 facts to calculate an angle (of a triangle) - you're only giving 2 (.5 and .75) - can you post a picture? :)
0
 
LVL 19

Expert Comment

by:Ken Butters
ID: 40013234
@gerwin in the authors clarification all three sides were given.

2 of the sides are 75. (The V)
1 of the sides is 50. (The base)
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40013278
@Ken - missed that :(
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40013327
PhilChapmanJr,

Your description of the situation is inadequate, so that the experts are having to guess what you mean.

Assuming that you are talking about two lines in the same plane, the best way to describe the lines is by their start and end points. This would which require four pairs of x and y co-ordinates, one pair for each end of each line.

Otherwise figures could simply refer to the gradients of each line. If so, the intersecting angle will be simply be the difference between the two angles.
0
 
LVL 2

Author Closing Comment

by:PhilChapmanJr
ID: 40013411
Thanks for your assistance.
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

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

656 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