Calculate Angle and Length in Triangle

C

Cathy

I have a Spreadhset with the following representing two sides of a Triangle

Angle Length
Side1, 20 35
Side2, 45 30
Side3,


I need a formula to calculate the Angle (degrees) and Length for the third
Angle

TIA
C
 
M

MadZebra

angle3 = 180 - ( angle1 + angle2 )
side3 is a bit trickier, must be a formula out there somewhere on the net
though.
Will have a think about that...
 
D

Dave Peterson

Your data doesn't describe a triangle.

Angle Length
Side1 20 35
Side2 45 30
Side3

If you had:

Angle Length
Side1 20 35
Side2 30
Side3

Then the triangle would be:

Angle Length
Side1 20 35
Side2 17 30
Side3 143 61.65

======

If you had:

Angle Length
Side1 20 35
Side2 45
Side3

Then the triangle would be:

Angle Length
Side1 20 35
Side2 45 72.36
Side3 115 92.75


Sometimes, too much information isn't a good thing!
 
C

Cathy

And sometimes too little information....

The angle provided is not the angle of a corner. It is the angle of the line
(or direction the line is pointing in with 0 degrees being at horizontally
pointing up, 90 degrees pointing vertically to the right etc.)

Regards
C
 
C

Cathy

Your data doesn't describe a triangle.

If you had:

Angle Length
Side1 20 35
Side2 30
Side3

Then the triangle would be:

Angle Length
Side1 20 35
Side2 17 30
Side3 143 61.65
That would contain the formula I would need, as I can calculate Angle by
deducting Angle1 from Angle2

Would be much obliged if you could share the formula used to calculate the
blanks in this example you showed.
 
M

michael.beckinsale

Hi Cathy,

If this is a follow up to the post l helped you with earlier in the
week then you need to change these 2 lines:

TiltValue = Range("A1").Value / 6
Theta = (TiltValue / 60 ) * TwoPI

to:

TiltValue = Range("A1").Value
Theta = (TiltValue * (PI/180))

or:

TiltValue = Range("A1").Value / 6
Theta = Radians(TiltValue)

If you look up COS and RADIANS in Excel help you will get explanations
& examples. It saved me having to get out all those geometry books!

Regards

Michael
 
C

Cathy

Thanks again for that Michael

It is not quite a follow on from the previous mail but forms part of the
same spreadsheet.

The previous mail was to enable a visual illustration of what was happening.
I did get your correction on changing the lines to show degrees and this
works a treat. I thank you dearly for this.

This part merely wants to calculate the values using formulaand display the
values in cell.

I will have to look at this over the weekend as I have to get out now before
the weather turns.

Have a nice day
C
 
D

Dana DeLouis

Sounds to me like you are doing simple Vector addition.

Just guessing of course, but a Vector (r, Theta) to (x,y,z) might be:
(Change Degrees to Radians, z is zero)

{r*Cos[d*Degree], r*Sin[d*Degree], 0}

Hence:

v1 = Vector[35, 20]

{35*Cos[20*Degree], 35*Sin[20*Degree], 0}

v2 = Vector[30, 45]

{15*Sqrt[2], 15*Sqrt[2], 0}


Add your x,y, & z 's together (z is zero)

The general equation from x,y,z to a Vector (r, Theta,z) is:

{Sqrt[x^2 + y^2], ArcTan[x, y], z}


If I cheat and use a math program...

v3 = CoordinatesFromCartesian[v1 + v2, Cylindrical]

{63.468467389538915, 0.5501802241799797, 0.}

Side: 63.468
Angle: 0.55 Radians

or 31.523 Degrees


{63.468467389538915, 31.52300481707432, 0.}

Again, just guessing.
 
D

Dana DeLouis

Here's my best guess using vba.

Returns:
Side: 63.4684673895389
Angle: 31.5230048170743


Sub Demo()
Dim v1, v2, x, y, v
'Vector to x & y
v1 = FromVector(35, 20)
v2 = FromVector(30, 45)
With WorksheetFunction
'Vector Addition
v = .Transpose(.Transpose(Array(v1, v2)))
x = .Sum(.Index(v, 0, 1))
y = .Sum(.Index(v, 0, 2))
Debug.Print " Side: " & Sqr(.SumX2PY2(x, y))
Debug.Print "Angle: " & .Degrees(.Atan2(x, y))
End With
End Sub

Function FromVector(r, th)
'// Angle th in Degrees
Dim A
A = WorksheetFunction.Radians(th)
FromVector = Array(r * Cos(A), r * Sin(A))
End Function

--
HTH :>)
Dana DeLouis


Dana DeLouis said:
Sounds to me like you are doing simple Vector addition.

Just guessing of course, but a Vector (r, Theta) to (x,y,z) might be:
(Change Degrees to Radians, z is zero)

{r*Cos[d*Degree], r*Sin[d*Degree], 0}

Hence:

v1 = Vector[35, 20]

{35*Cos[20*Degree], 35*Sin[20*Degree], 0}

v2 = Vector[30, 45]

{15*Sqrt[2], 15*Sqrt[2], 0}


Add your x,y, & z 's together (z is zero)

The general equation from x,y,z to a Vector (r, Theta,z) is:

{Sqrt[x^2 + y^2], ArcTan[x, y], z}


If I cheat and use a math program...

v3 = CoordinatesFromCartesian[v1 + v2, Cylindrical]

{63.468467389538915, 0.5501802241799797, 0.}

Side: 63.468
Angle: 0.55 Radians

or 31.523 Degrees


{63.468467389538915, 31.52300481707432, 0.}

Again, just guessing.
--
Dana DeLouis



Cathy said:
And sometimes too little information....

The angle provided is not the angle of a corner. It is the angle of the
line (or direction the line is pointing in with 0 degrees being at
horizontally pointing up, 90 degrees pointing vertically to the right
etc.)

Regards
C
 
C

Cathy

Hi Dana

Drawing this on paper, suggests that the third lines length should be much
shorter than the other two lines.
 
D

Dana DeLouis

Drawing this on paper, suggests that the third lines length should be much
shorter than the other two lines.

Hard to tell, but did you draw both given lines from the same origin (ie at
(0,0)) using the two angles given?
If so, then if I Subtract both vectors, I get a distance of
14.891395073096243.
Again, it's hard to tell from your discription.
 
P

Peter T

Like Dave, I don't think the details you provided describe a possible
triangle, where Angle1 is opposite Side1 etc

Afraid I don't follow your further description of what the angle(s?) relate
to at all.

Anyway, I think the formula you want is -

c = SQRT(a^2 + b^2 - 2*a*b*COS((180-A-B)*PI()/180))

If angles A & B are not internal angles opposite sides a & b adapt as
required, particulary this bit (180-A-B) the angle opposite the unknown side
length to be resolved.

Regards,
Peter T

PS the above formula validates Dave's "would be" triangles.
 
C

Cathy

Sorry if I am confusing things by not explaining 100%

This is very usefull to me as my head is hurting going through Trig websites
trying to remember everything again.

Okay let me try again from scratch

# A B C
1 Side Direction Length
2 Line1 20 35
3 Line2 45 30
4 Line3 ? ?

Three lines form a triangle. Lets call it Triangle ABC with these letters on
each of the corners
(it is not a right Triangle)
Line1 = a = AB
Line2 = b = BC
Line3 = c = CA

Line1 starts at position 0.0
Line1 is angled at 20 degrees from 0 (0 being horizontal)
Line1 is 35 meters long

Line2 starts at position 0.0 also
Line2 is angled at 45 degrees from 0
Line2 is 30 meters long

The difference in angle between Line1 and Line2 is therefore 25 degrees

Line3 completes the Triangle
Need to calculate angle from 0
Need to calculate length

Therefore using Daves Example the angle of side1 would be 25
If you had:
# A B C
1 Angle Length
2 Side1 25 35
3 Side2 ? 30
4 Side3 ? ?

And therefore I have to calculate three values
If formulas for these three can be provided, then I will be very happy.

Hope this makes a little more sense now. (Wish I could draw it as I see it
in text)

TIA
C
 
D

Dana DeLouis

Line1 starts at position 0.0
Line2 starts at position 0.0
Need to calculate angle from 0

Sure sounds like Vectors:

Length: 14.891395073096243

Angle (Depending on which direction):
141.6356275088955
or: -38.364372491104476
 
P

Peter T

OK I follow now.

The internal angle between lines a & b is 45-20=25. This angle is opposite c
and is thus Angle-C

Referring to the formula I posted previously

c = SQRT(a^2 + b^2 - 2*a*b*COS((180-A-B)*PI()/180))

change (180-A-B) to 25 and include the known side lengths a & b

= SQRT(35^2+30^2-2*35*30*COS(25*PI()/180))

= 14.8913950730962

Somehow Dana managed to obtain an extra 2dp of precision beyond the
capabilities of my Excel <g>

Regards,
Peter T
 
P

Peter T

I forgot about the 'other' angle. First the formula to calculate an internal
angle from three known side lengths -

A=ACOS((b^2+c^2-a^2)/(2*b*c))*180/PI()

or as you want internal Angle-B
B=ACOS((a^2+c^2-a^2)/(2*a*c))*180/PI()

=ACOS((35^2+14.8913950730962^2-30^2)/(2*35*14.8913950730962))*180/PI()

= 58.36437249

Deduct your original 20, elevation of lineA from the horizontal
=38.3643724911045

or depending on direction
= 141.635627508895

Regards,
Peter T
 
C

Cathy

I thank you both for your all this

Your formula is perfect. I just had difficulty relating your references to
A,a,B,b,C and c.

Again I realise this is probably due to a mistake in my discription. All
this trig stuff is all slowly coming back to me.

What I should have said was
Line1 = b = AC = 20° from 0° = 35 meters
Line2 = c = AB = 45° from 0° = 30 meters
Line3 = a = CB = ?° from 0° = ? Meters
(I simply forgot that side "a" would be opposite to corner "A" :)

Going by the above then
A = BAC = 45° - 20° = 25°
A=ACOS((b^2+c^2-a^2)/(2*b*c))*180/PI()
I already have A. It is 25°
or as you want internal Angle-B
B=ACOS((a^2+c^2-a^2)/(2*a*c))*180/PI()
?Should this not read:
B=ACOS((a^2+c^2-b^2)/(2*a*c))*180/PI()

Is the following therefore correct?
A°=BAC=25°
B°=ABC=ACOS((a^2+c^2-b^2)/(2*a*c))*180/PI() = 96.63893451
C°=ACB=ACOS((b^2+a^2-c^2)/(2*a*b))*180/PI() = 58.36374786

And modelling by previous spreadsheet
# A B C
1 Side Direction Length
2 Line1 20 35
3 Line2 45 30
4 Line3 ? ?

The formula for B4 is:
=180-(ACOS((C4^2+C2^2-C3^2)/(2*C4*C2))*180/PI())+B2
= 141.6362521°

and Formula for C4 is:
=ROUND(SQRT(C2^2+C3^2-2*C2*C3*COS((B3-B2)*PI()/180)),2)
=14.89139507 meters

I have just realised another mistake in my original example, i.e. the angle
of c should have been in the opposite direction. I should be able to work
that out myself and correct what I am trying to achieve.

Thank you so much for all your help.

Kind regards
C
 
D

Dana DeLouis

I have just realized another mistake in my original example, i.e. the
angle of c should have been in the opposite direction.

I think you want to describe vector bc in both its Magnitude, and Direction.
You have to keep track of both the internal angles, and a reference angle to
make corrections to get the correct answer.
I was just suggesting an alternate method to avoid keeping track of all
that.
Since this is in a programming group, I was just suggesting subtraction like
this:
v1 = Vector(35, 20)
v2 = Vector(-30, 45)
'...etc

Don't forget an angle below the horizon is negative.

=DEGREES(ATAN((3*SQRT(2)-7*SIN(RADIANS(20)))/(3*SQRT(2)-7*COS(RADIANS(20)))))

-38.3643724911045

(Add 180 to get opposite "direction" of 141.635627508896)


On technique I like to use is to define a Named Constant in Excel to help
convert Degrees to Radians.
For Example:
Deg = Pi()/180

Hence, an alternative for Length might be:

=5*SQRT(85 - 42*SQRT(2)*COS(20*Deg) - 42*SQRT(2)*SIN(20*Deg))

14.8913950730962

Maybe something of interest
http://en.wikipedia.org/wiki/Vector_(spatial)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top