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: 143
  • atan.jpg
    atan.jpg
    30.4 KB · Views: 139
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Â"??
 
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Back
Top