TheSwamp

CAD Forums => CAD General => Topic started by: alanjt on June 20, 2013, 09:31:21 PM

Title: Math question: find height from distance and two angles
Post by: alanjt on June 20, 2013, 09:31:21 PM
I'm totally blanking on how to find the height and I can't find the solution on line. Could someone much smarter than I am please tell me how?

I have two angles: 90°53'36" and 85°26'05", with a distance of 205.12'.

Thanks, guys.
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 20, 2013, 10:33:39 PM
I am not sure I understand your problem correctly but if that is a triangle with two angles and a side between them, this should work.

Code: [Select]
(defun dtr (x)
(* pi (/ x 180.000)))

(defun tan (xx)
(/ (sin xx)(cos xx)))

(setq a (- pi (dtr 90.8933333333))
      b (dtr 85.434722222)
      d 205.12
      h (/ (* (tan b) d (tan a))(- (tan a)(tan b))))
Title: Re: Math question: find height from distance and two angles
Post by: Kerry on June 20, 2013, 11:03:33 PM
Alan, We want pictures ! 

:)
Title: Re: Math question: find height from distance and two angles
Post by: diarmuid on June 25, 2013, 07:30:03 AM
Not being crazy but, given the information, could you not just draw the triangle in AutoCAD and then measure from it?
Title: Re: Math question: find height from distance and two angles
Post by: Rob... on June 25, 2013, 07:31:46 AM
That's what I would have done but was thinking the OP wanted the mathematical solution.
Title: Re: Math question: find height from distance and two angles
Post by: alanjt on June 25, 2013, 08:15:48 AM
Yes, I could have just done it in cad, but I couldn't remember the formula and that's what I was looking for.

BTW, thank you, Paul.
Title: Re: Math question: find height from distance and two angles
Post by: CAB on June 25, 2013, 08:49:46 AM
Alan,
Do you have Terry's routine?
Code: [Select]
;|
Here is  a TRI  function that  I wrote  last year  for calculating the sides and
angles of right and oblique triangles.  The function is fairly easy to  use.  It
has six arguments:  Side s1, Side  s2, Side s3,  Angle a, Angle  b, and Angle c.
Angles are  in radians.   It returns  a 1  based list  so you  can use the ‘nth’
function to retrieve your results.   To display the text help  information, just
type (tri ? ? ? ? ? ?) on the command line as follows:
Note: This displays better using a courier or mono-spaced font.
Command: (tri ? ? ? ? ? ?)
tri error: (tri nil nil nil nil nil nil)
Only 2 or 3 valid arguments can be passed to tri function.
tri - Calculates the sides and angles of a triangle
Arguments: 6             |\                /\
  s1 = Side s1           |a\              /a \
  s2 = Side s2           |  \            /    \
  s3 = Side s3        s2 |   \ s3    s2 /      \ s3
  a = Angle a radians    |    \        /        \
  b = Angle b radians    |c___b\      /c________b\
  c = Angle c radians      s1              s1
Syntax example: (tri 3 ? ? 0.643501 ? ?);where ? = nil
Returns: (list nil 3.0 4.0 5.0 0.643501 0.927295 1.5708)
Note: For right triangles only supply the argument values for 2 sides,
or 1 side and 1 angle. Use ? or nil for the Angle c argument value.
For oblique triangles only supply argument values for 3 sides,
or 2 sides and 1 angle, or 1 side and 2 angles.
|;

;-------------------------------------------------------------------------------
; tri - Calculates the sides and angles of a triangle
; Arguments: 6             |                 /\
;   s1 = Side s1           |\               /a \
;   s2 = Side s2           |a\             /    \
;   s3 = Side s3        s2 |  \ s3     s2 /      \ s3
;   a = Angle a radians    |   \         /        \
;   b = Angle b radians    |c__b\       /c________b\
;   c = Angle c radians      s1              s1
; Syntax example: (tri 3 ? ? 0.643501 ? ?);where ? = nil
; Returns: (list nil 3.0 4.0 5.0 0.643501 0.927295 1.5708);nth 1 based list
; Note: For right triangles only supply the argument values for 2 sides, or
; 1 side and 1 angle. Use ? or nil for the Angle c argument value. For oblique
; triangles only supply argument values for 3 sides, or 2 sides and 1 angle,
; or 1 side and 2 angles.
; Programming example usages:
; (setq Side2 (nth 2 (tri 3 ? ? 0.643501 ? ?))) = 4.0
; (setq AngleB (nth 5 (tri 3 ? ? 0.643501 ? ?))) = 0.927295
Title: Re: Math question: find height from distance and two angles
Post by: alanjt on June 25, 2013, 08:52:58 AM
Alan,
Do you have Terry's routine?
Code: [Select]
;|
Here is  a TRI  function that  I wrote  last year  for calculating the sides and
angles of right and oblique triangles.  The function is fairly easy to  use.  It
has six arguments:  Side s1, Side  s2, Side s3,  Angle a, Angle  b, and Angle c.
Angles are  in radians.   It returns  a 1  based list  so you  can use the ‘nth’
function to retrieve your results.   To display the text help  information, just
type (tri ? ? ? ? ? ?) on the command line as follows:
Note: This displays better using a courier or mono-spaced font.
Command: (tri ? ? ? ? ? ?)
tri error: (tri nil nil nil nil nil nil)
Only 2 or 3 valid arguments can be passed to tri function.
tri - Calculates the sides and angles of a triangle
Arguments: 6             |\                /\
  s1 = Side s1           |a\              /a \
  s2 = Side s2           |  \            /    \
  s3 = Side s3        s2 |   \ s3    s2 /      \ s3
  a = Angle a radians    |    \        /        \
  b = Angle b radians    |c___b\      /c________b\
  c = Angle c radians      s1              s1
Syntax example: (tri 3 ? ? 0.643501 ? ?);where ? = nil
Returns: (list nil 3.0 4.0 5.0 0.643501 0.927295 1.5708)
Note: For right triangles only supply the argument values for 2 sides,
or 1 side and 1 angle. Use ? or nil for the Angle c argument value.
For oblique triangles only supply argument values for 3 sides,
or 2 sides and 1 angle, or 1 side and 2 angles.
|;

;-------------------------------------------------------------------------------
; tri - Calculates the sides and angles of a triangle
; Arguments: 6             |                 /\
;   s1 = Side s1           |\               /a \
;   s2 = Side s2           |a\             /    \
;   s3 = Side s3        s2 |  \ s3     s2 /      \ s3
;   a = Angle a radians    |   \         /        \
;   b = Angle b radians    |c__b\       /c________b\
;   c = Angle c radians      s1              s1
; Syntax example: (tri 3 ? ? 0.643501 ? ?);where ? = nil
; Returns: (list nil 3.0 4.0 5.0 0.643501 0.927295 1.5708);nth 1 based list
; Note: For right triangles only supply the argument values for 2 sides, or
; 1 side and 1 angle. Use ? or nil for the Angle c argument value. For oblique
; triangles only supply argument values for 3 sides, or 2 sides and 1 angle,
; or 1 side and 2 angles.
; Programming example usages:
; (setq Side2 (nth 2 (tri 3 ? ? 0.643501 ? ?))) = 4.0
; (setq AngleB (nth 5 (tri 3 ? ? 0.643501 ? ?))) = 0.927295
I do not, but that looks rather impressive.
Title: Re: Math question: find height from distance and two angles
Post by: ribarm on June 25, 2013, 09:24:36 AM
Alan, in case you didn't google it, here is link :

http://www.theswamp.org/index.php?topic=15698.msg191722#msg191722
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 25, 2013, 09:36:04 AM
Yes, I could have just done it in cad, but I couldn't remember the formula and that's what I was looking for.

BTW, thank you, Paul.

You are welcome.
Here is how I came to the formula (attached). No Google.
Title: Re: Math question: find height from distance and two angles
Post by: CAB on June 25, 2013, 10:15:31 AM
Thanks for the link, I was missing that.  8)

Alan, in case you didn't google it, here is link :

http://www.theswamp.org/index.php?topic=15698.msg191722#msg191722 (http://www.theswamp.org/index.php?topic=15698.msg191722#msg191722)
Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 25, 2013, 09:19:39 PM
I am not sure I understand your problem correctly but if that is a triangle with two angles and a side between them, this should work.

Code: [Select]
(defun dtr (x)
(* pi (/ x 180.000)))

(defun tan (xx)
(/ (sin xx)(cos xx)))

(setq a (- pi (dtr 90.8933333333))
      b (dtr 85.434722222)
      d 205.12
      h (/ (* (tan b) d (tan a))(- (tan a)(tan b))))

Sorry, I think the height in your code should be:
(setq h (/ (* (tan b) d (tan a)) (+ (tan a) (tan b))))
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 25, 2013, 09:44:45 PM
I disagree
Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 25, 2013, 10:19:58 PM
I disagree
Have you tried what Alan given and drawn it in AutoCAD?
Angle 1 = 90.8933333333 deg
Angle 2 = 85.434722222 deg
Distance = 205.12
What would you get for the height?
Would it be the same as what you calculated from your code?
Thanks.
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 25, 2013, 10:32:09 PM
Yes, I did draw it and measured to verify my code result. See the attached drawing in my second post here.
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 25, 2013, 10:39:25 PM
Your correction would work only if both angles were less than 90 deg.
Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 25, 2013, 11:10:48 PM
Your correction would work only if both angles were less than 90 deg.
Not really. It works for angles greater than 90deg as well.

From your code the height = 3192.2655
while the height measured on the drawing = 2149.1800, which is based on these:
Angle a = 90.8933333333 deg
Angle b = 85.434722222 deg
Distance = 205.12
Title: Re: Math question: find height from distance and two angles
Post by: Kerry on June 26, 2013, 12:33:43 AM
I think you guys need to go back and define your terms.

The decision to add or subtract the divisor components depends on the way the larger angle is measured.
You are using different criteria.
Title: Re: Math question: find height from distance and two angles
Post by: Kerry on June 26, 2013, 12:58:53 AM
For instance :
using the internal angles as per the sketch attached is correct.

Using (- pi (dtr 100)) as Paul has done requires the divisor components be negated (as he has done).

So you are both correct, or both incorrect or whatever
Title: Re: Math question: find height from distance and two angles
Post by: Kerry on June 26, 2013, 01:14:44 AM
In answer to a PM.
The app is 'Pencil' ..
http://pencil.evolus.vn/Features.html
Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 26, 2013, 01:16:29 AM
Thanks to Kerry's explanations.

OK, lets go back to the starting point.
I don't know if Alan has already looked Paul's drawing.
I know that is not easy when translating the words to the drawing.
Generally speaking, our discussions should be all based on the same coordinate system, which means that all angles measured anticlockwise from X axis.
By looking at your drawing, the angle "A" you described actually differs to what Alan given.
Alan's: 90°53'36"
and yours: 180° - 90°53'36" = 89°06'24"
This explains why you got the height of 3192.2655
In other words, the angle "A" in your code can be simplified to:
(setq a (dtr 90.8933333333))

I attache my version here. Hope I have not misunderstood Alan's issue.
Title: Re: Math question: find height from distance and two angles
Post by: Kerry on June 26, 2013, 01:21:51 AM
MeasureUp,
Your triangles are acute ;
Pauls is obtuse


I guess this whole thread is a perfect example of one of my favourite topics .. making sure we are all answering the correct question.

added:
For what it's worth, my assumptions about the problem were the same as Pauls ie the angles given represented the internal triangle angles.

Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 26, 2013, 01:34:42 AM
MeasureUp,
Your triangles are acute ;
Pauls is obtuse


I guess this whole thread is a perfect example of one of my favourite topics .. making sure we are all answering the correct question.
Thanks Kerry, again.
We shall now wait and see what Alan will say.  :-D
Of course, Paul can check if I haven't miss any points from you.
Title: Re: Math question: find height from distance and two angles
Post by: paulmcz on June 26, 2013, 07:16:02 AM
As Kerry is saying, your triangle is acute. But, Alan specified one angle acute and the other obtuse.
Title: Re: Math question: find height from distance and two angles
Post by: CAB on June 26, 2013, 08:49:36 AM
Strange, I would always assumed we were talking Internal Angles with a triangle.
Other wise the orientation of the triangle comes into play.  :o

Title: Re: Math question: find height from distance and two angles
Post by: Rob... on June 26, 2013, 08:59:22 AM
Strange, I would always assumed we were talking Internal Angles with a triangle.

<fake southern drawl>That's the way I was learnt to do it.
Title: Re: Math question: find height from distance and two angles
Post by: MeasureUp on June 26, 2013, 08:42:25 PM
By looking at Paul's drawing again, lets think in this way, we now draw 2 construction lines.
One to the angle of 90.8933333333deg and another to 85.434722222deg.
If the 1st one placed on left while the 2nd on the right, we all know that they never intersect physically.
This is what the info was given by Alan.
It only makes sense if the 1st construction line drawn on the right.
Agree?
If we have a building/civil/survey background, we may better understand the info which Alan's given.
Hope I have explained what I think clearly.