MHB Convert rise and run (slope) to degrees using simple formulas

AI Thread Summary
The discussion centers on converting rise and run (slope) to degrees using Ruby programming. The user initially struggled with the Arc Tangent function, obtaining results in radians instead of degrees. A solution was provided, emphasizing the need to multiply the result by 180 divided by Math::PI to convert to degrees. The user confirmed that the formula (Math.atan2(y_position,x_position)*180)/Math::PI worked for their needs. Additionally, there was a query about a formatting issue where a long decimal number was altered in the post.
Alaskan Son
Messages
13
Reaction score
0
I'm looking for a little help here. I'm just a relatively regular Joe here though, so any complicated formulas are likely to go right over my head. What I'm trying to do is use the Ruby programming language to convert rise and run (slope) to degrees. See the attached screenshot...

View attachment 8617

Assume x and y-axis are constant and that point a is always at 0,0. I want to use dimension d and e to obtain an angle in degrees. In this example:

d = 334.385384
e = 187.413131

I happen to know that angle c = approx. e° due to some tools I have available in my CAD program, but I really want to be able to plug d and e into a formula so I can get some automated feedback using some Ruby scripting. Ruby has an Arc Tangent function...

View attachment 8618

...but I'm really not sure how to use it. I tried using atan(e/d) but that results in 0.5108463979434283

I'd love if someone could help me understand what I'm doing wrong. Thanks.
 

Attachments

  • Degrees.jpg
    Degrees.jpg
    20.6 KB · Views: 150
  • atan.jpg
    atan.jpg
    30.4 KB · Views: 140
Mathematics news on Phys.org
Alaskan Son said:
I'm looking for a little help here. I'm just a relatively regular Joe here though, so any complicated formulas are likely to go right over my head. What I'm trying to do is use the Ruby programming language to convert rise and run (slope) to degrees. See the attached screenshot...
Assume x and y-axis are constant and that point a is always at 0,0. I want to use dimension d and e to obtain an angle in degrees. In this example:

d = 334.385384
e = 187.413131

I happen to know that angle c = approx. e° due to some tools I have available in my CAD program, but I really want to be able to plug d and e into a formula so I can get some automated feedback using some Ruby scripting. Ruby has an Arc Tangent function...
...but I'm really not sure how to use it. I tried using atan(e/d) but that results in 0.5108463979434283

I'd love if someone could help me understand what I'm doing wrong. Thanks.

Hi Alaskan Son,

I presume your problem is that you want the angle in degrees?

You are getting the result in so called radians.
To get degrees you need to multiply by [m]180 / Math::PI[/m].
So for instance [m]atan2(1,1) * 180 / Math::PI[/m] = 45.
 
Just as an aside, I recommend that you be consistent with the way you label your axis. For instance, moving counter clockwise from axis labelled 0 degrees in your diagram, we go to +90, +180, +270 (not -90) and then +360 = 0. This might not be an issue now, but later on it might make things a little awkward. In general, it's good to fix any conventions/rules from the beginning.

I usually go one step further when dealing with this situation and modulo the output of atan2 such that the result is a positive angle measured counterclockwise.
 
Klaas van Aarsen said:
Hi Alaskan Son,

I presume your problem is that you want the angle in degrees?

You are getting the result in so called radians.
To get degrees you need to multiply by [m]180 / Math::PI[/m].
So for instance [m]atan2(1,1) * 180 / Math::PI[/m] = 45.

Awesome! Thanks : )

- - - Updated - - -

Joppy said:
Just as an aside, I recommend that you be consistent with the way you label your axis. For instance, moving counter clockwise from axis labelled 0 degrees in your diagram, we go to +90, +180, +270 (not -90) and then +360 = 0. This might not be an issue now, but later on it might make things a little awkward. In general, it's good to fix any conventions/rules from the beginning.

I usually go one step further when dealing with this situation and modulo the output of atan2 such that the result is a positive angle measured counterclockwise.

Thanks you, but I purposely labeled them like that. Those are the way angles are used in my drafting program and my goal is to have angles that report in those exact formats. Now that I have the proper formula, I think I can make it work.

Actually, upon further investigation, the following formula results in exactly what I was looking for...

(Math.atan2(y_position,x_position)*180)/Math::PI

Thanks again guys.

- - - Updated - - -

Alaskan Son said:
...I happen to know that angle c = approx. e° ...

Just curious. I actually entered a long decimal angle number in my post yesterday. It was automatically changed after I posted it though and I didn't realize it until now. Do you guys happen to know why my number might have been changed to "eÂ"??
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top