Re: Calculate Angle and Length in Triangle

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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" <ddelouis@xxxxxxxxxxxxx> wrote in message
news:ev6vhZueIHA.4476@xxxxxxxxxxxxxxxxxxxxxxx
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" <Cathy@xxxxxxxxxx> wrote in message
news:13sfhova6onje34@xxxxxxxxxxxxxxxxxxxxx
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




.


Quantcast