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

In summary, Alaskan Son is trying to use the Arc Tangent function in Ruby to calculate the angle in degrees between two points. He is having trouble getting the result he wants and is looking for help. He finds the solution by using the previously mentioned formula and is grateful for the help.
  • #1
Alaskan Son
13
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: 68
  • atan.jpg
    atan.jpg
    30.4 KB · Views: 71
Mathematics news on Phys.org
  • #2
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.
 
  • #3
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.
 
  • #4
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Â"??
 

1. What is the formula for converting rise and run to degrees?

The formula for converting rise and run to degrees is arctan(rise/run) x 180/π. This formula uses the arctangent function to find the angle in radians, which is then multiplied by 180 degrees and divided by π to get the angle in degrees.

2. How do I determine the rise and run values to use in the formula?

The rise and run values are determined by measuring the vertical and horizontal distances between two points on a line. The rise is the vertical distance, while the run is the horizontal distance.

3. Can the slope be negative?

Yes, the slope can be negative. A negative slope indicates that the line is decreasing from left to right, while a positive slope indicates that the line is increasing from left to right.

4. How do I convert a slope in degrees to a rise and run value?

To convert a slope in degrees to a rise and run value, you can use the formula rise = tan(degrees) x run. This formula uses the tangent function to find the ratio of the rise to the run, which can then be used to determine the actual rise and run values.

5. Are there any online tools or calculators for converting rise and run to degrees?

Yes, there are several online tools and calculators available for converting rise and run to degrees. These tools use the formula mentioned in question 1 to perform the conversion and provide accurate results.

Similar threads

Replies
6
Views
1K
  • General Math
Replies
13
Views
1K
Replies
2
Views
1K
Replies
24
Views
1K
  • Special and General Relativity
Replies
5
Views
1K
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
717
  • Introductory Physics Homework Help
Replies
2
Views
2K
Back
Top