Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - a Different sort of Triangle Value Calculation 1

Status
Not open for further replies.

astrogirl77

Programmer
Aug 14, 2008
45
0
0
CA

Help - a Different sort of Triangle Value Calculation

I'm looking for some help with computing values of a triangle and then drawing it to screen

Known;

Two points in degrees exist on a circle

Two line lengths representing ;

base, adjacent side (a)

and

opposite (c)

we want to derive side (b) hypotenuse

and also angles (A), (B), (C)

We already know that sides (a) and (c) join and we know that the longest side length will not exceed the diameter of the circle that the triangle is circumscribed within

The triangle created will be variable as different degrees and side lengths are entered, typically this will be scalene triangles but the may also be at times right triangles

I've been using a derived arc cos function ;

------------------------------------------------------------------------
Public Function Arccos(X As Double) As Double
Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function
------------------------------------------------------------------------

I know we can convert degrees to radians via "* Pi) / 180"

I know I can get the hypotenuse by;

------------------------------------------------------------------------
side_b_squared = CDbl(c1 ^ 2 + a1 ^ 2 - (c1 * a1)) * Cos(angle_B_degree_value_radians)
b1 = Sqr(side_b_squared)
------------------------------------------------------------------------

I know we can get the angles A,B,C via ;

------------------------------------------------------------------------
angle_C_cos_value = CDbl(a1 ^ 2 + b1 ^ 2 - c1 ^ 2) / (2 * (a1 * b1))
angle_B_cos_value = CDbl(c1 ^ 2 + a1 ^ 2 - b1 ^ 2) / (2 * (c1 * a1))
angle_A_cos_value = CDbl(b1 ^ 2 + c1 ^ 2 - a1 ^ 2) / (2 * (b1 * c1))
angle_C_acos_value = (Arccos(angle_C_cos_value))
angle_B_acos_value = (Arccos(angle_B_cos_value))
angle_A_acos_value = (Arccos(angle_A_cos_value))
angle_C_degree_value = angle_C_acos_value * 180 / Pi
angle_B_degree_value = angle_B_acos_value * 180 / Pi
angle_A_degree_value = angle_A_acos_value * 180 / Pi
------------------------------------------------------------------------

Although, I've had some trouble with this since some of the returned angles for some previous testing I did didn't
seem to be working very well, for instance I'd enter 60 degrees for angle (B) but it would somehow crunch it to

angle_B_Degree Value 38.8700377933938

I'm a little stuck on the math for all this.... here is an example scenario that I hope illustrates really clearly what I'm trying to do ;

A small VB app does the following ;

A small circle is drawn to the screen

On the form of the VB app there are text boxes that accept inputs ;

Text 1 = side (c) length as a number
Text 2 = side (a) length as a number

Text 3 = a value in degrees that represents a point of one of the ends of side (c)
Text 4 = a value in degrees that represents a point of one of the ends of side (a)

Then the following are computed ;

side length of the hypotenuse as a number, and output to a different text box

Angles (A), (B), (C) are computed as values in degrees, and output to another text box

The drawn circle may be say four inches in diameter, and all side lengths computed, regardless of their number value
are fit proprotionally, circumscribed within the circle, so even if one of the side lengths is really long, all side lengths are fit proportionally in the circle but retaining the same intrinsic unit measure values of their lengths.

Any help or insights on the above are really appreciated, especially the math and formula end and any code ideas, samples are a God send.

I'm a bit of a newbie with all this and I'm using an older version of VB (4.0)

I have a basic idea on using some of the draw functions and I think I can tinker my way through this, but again am very open to any feedback

Thanks people!

:)
 
What tutorial does this come from?

Since the "problem" statement requires a circumscribed triangle, the other ends of the lines must also be concident with the circle.

If the end points of the given lines are not coincident, the third line must be ()between) the two given points. Then the non-desiginated end points of the given lines must also be coincident with the circle.

The sum of the lengths of the two given lines must be greater than the length of the line AC (otherwise the other ends cnnot be coincident and thus no such triangle exists .

If the two given points are NOT coincident, we now have all three lines (lengths) BUT this may not result in a "circumsized triangle.

If the two given points are coincident, you nreed to find the unknown end points of the given lines. There are two possible positions of each of these lines, or four points which MAY provide two lines which intersect along the arc of the circle. I would not expect the result to be unique, so some constraint would need to be relaxed, and your soloution would then need to clarify what the priorities of further processing.

In a general sense, you will eventually defins (solve for) three chords of the circle. if you constrain the given end points to be non coincident, these two points provide one such chord. The other possible chords are the llines formed from the given points and the lengths of the lines where they intersect the circle. A (simple?) exercise to determine the chords should be available from any number of sources.



MichaelRed


 
I just realized I made an assumption that may not be correct at all.

I had thought earlier that if we knew two points in degrees on the circle, then the difference or sum between them must be either one of the values of te unknown internal angle, or at least it would represent the other 3rd unknown point on the circle.

Now I'm thinking that, thats just a poor guess on my part!
:(

Although, I then realized that if we knew two of the lengths of two of the sides, and if we knew that each line was associated with one of the points, then one of the lines must also intersect the two known points, and since that is the case then if the line that joins the two points is not equal to either of the two known line lengths then that gives us the missing side!? (And you also pointed that out to me! Thank you!)

If thats the case then its a matter of deriving where the third unknown point in degrees on the circle would be where the two known line lengths would meet?

I'm guessing, but if I'm not mistaken there could only be a maximum of two specific points on the circle where these two lines could join? But maybe only one place?
I'm hoping there is a way to 'algebra-tize' all this and then code it!? :)

Also, this is really important I feel ;

The lines of the triangle will be variable and in generic units, but say we know that the diameter of the circle is four inches. Line lengths may be values of 10, 23, 5, what ever... but they will fit proportionately in the circle, so the lines of generic unit measure need to be fit within the circle.

Here, we only know two of the points on the circle

In this exercise we don't know any of the internal angles, all we know are two points in degrees on the circle (the third is unknown) and we know that each point will be associate with one of the two known line lengths

We have the following unknowns;

All three internal angles, and one of the side lengths

All we know is two side lengths, two points on the circle in degrees where each point is associated with one of the side lengths, and we know which point on the circle is associate with which line,
We also know that the two known points on the circle must join and that this line may or may not be one of the known lines. Some sort of check, if statement could verify it when measured
proprtionately somehow and if its not one of the known line lengths then we have our third unknown line


 
When you say "Circumsized" it means the three (3) verticies are all points on the circumfrence of the circle. This means the line ("Chord") between the two points is the third line (and its length).

We 'know' the lengths of all three sides.

What 'we' do not know, is where the unkbown third point is on the circle circumfrence. (see the 1st paragraph above).

Each side of the triangle is (again, see deffinition of "Circumscribed") a chord of hte circle, and one end point is given for the two (2) lines which we know one end point and the length. Go get the information re CHORD.

Find the other two (2) possible end points for each of the two lines (that5 is a total of four (4) points. If any two points are coincident, that is the third vertice and you have the triangle. OTHERWISE, the given information does not provide a soloution.

Depending on your actual code, it may result in a triangle, just not a circumscribed one.



MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top