TheSwamp

Code Red => VB(A) => Topic started by: Patch61 on April 13, 2011, 01:06:56 PM

Title: Need help with math formula
Post by: Patch61 on April 13, 2011, 01:06:56 PM
I am writing a small tool that will return the linear distance between two points on a given slope. The slope will be given in rise:distance such as 4" in 12". I need to return the distance 'X' (as the crow flies) that is a given distance down (or up) the slope.

I slept through geometry at school, so can anybody help me figure out the formula?


Thanks!
Steve
Title: Re: Need help with math formula
Post by: Matt__W on April 13, 2011, 01:13:01 PM
And you're doing some sort of program using VBA?

Just checking because you didn't post any WIP code.
Title: Re: Need help with math formula
Post by: LE3 on April 13, 2011, 01:26:43 PM
an easy way is to use the 'rule of three'

for example:

side of triangle
a = 24
b = 8
c = 24 2 + 8 2
c = 576 + 64 root
c = 25.298

then
25.298 = 24
12.0 = X

X = 12.0 x 24.0 / 25.298 = 11.384
Title: Re: Need help with math formula
Post by: Kerry on April 13, 2011, 01:27:44 PM
x= 12 * Cos (atan (8/24))
~= 11.3842
Title: Re: Need help with math formula
Post by: dgorsman on April 13, 2011, 01:38:42 PM
All that stuff that the other kids kept saying "I'll never find a use for that" keeps coming up.

A right-angle triangle will have the same proportions if you scale it around one vertex.  Even though the sides are different lengths, the angles will be the same and the sides scale down (or up) to the same relative size.  Once you have one of the new lengths then the rest is just Pythagorean or trig.

Triangles are beautiful things in math.   :love:
Title: Re: Need help with math formula
Post by: Patch61 on April 13, 2011, 01:56:27 PM
Matt,

I didn't post code because I don't need help with code. I just need a formula. Can't post a 'FIP' (formula in progress) if I don't know where to start.  :wink:


Le and dgorsman,

I don't get why you are talking about triangles. I don't think I am trying to solve a triangle. I show a triangle to give clarity to my problem. The measurement that shows as 1' could be any number, unrelated to the the other numbers.  :|


Kerry,

Once again you have come through for me!  :laugh:


Thanks to all for trying to help!
Title: Re: Need help with math formula
Post by: LE3 on April 13, 2011, 02:14:27 PM
Le and dgorsman,

I don't get why you are talking about triangles. I don't think I am trying to solve a triangle. I show a triangle to give clarity to my problem. The measurement that shows as 1' could be any number, unrelated to the the other numbers.  :|
:-o
You are solving a triangle, and want to calculate one of the sides.
Title: Re: Need help with math formula
Post by: Lee Mac on April 17, 2011, 05:27:40 PM
I don't get why you are talking about triangles. I don't think I am trying to solve a triangle.

Kerry,
Once again you have come through for me!

Note that Kerry's solution directly uses right-angled triangle trigonometric identities, hopefully this small diagram clarifies things for you:

(http://www.theswamp.org/screens/leemac/RATrig.png)

Title: Re: Need help with math formula
Post by: Crank on April 17, 2011, 05:44:50 PM
or:
(http://www.theswamp.org/screens/Crank/Math.JPG)
Title: Re: Need help with math formula
Post by: Patch61 on April 20, 2011, 04:17:05 PM
Thanks for the clarification, guys!

I guess maybe high school was a bit important!