[VB6]Help with mathmatical coding.

Newbie Spellweaver
Joined
Oct 16, 2008
Messages
85
Reaction score
0
I'm coding a geometry type program as a project and as a bonus we need to be able to..

Give the Perimeter of a triangle given ONLY it's base and height. THe triangle can be scalene,isos,or equilateral.

I've even googled how to do it but none of them say how to do it given one side and the height.

A little help would be appreciated.
 
I'm coding a geometry type program as a project and as a bonus we need to be able to..

Give the Perimeter of a triangle given ONLY it's base and height. THe triangle can be scalene,isos,or equilateral.

I've even googled how to do it but none of them say how to do it given one side and the height.

A little help would be appreciated.

The triangle described only by base length and height is ambiguous. You can have a range of perimeters, and you can compute this range, but there is no one specific answer.

If you want me to show the math on how to compute the range of perimeters, I can do so.
 
Hai mate ^^

You could do this assuming that you can specify the type of triangle (therefore you know the angles in said triangle), and you would have to be able to assume that the point of the triangle was in the center of the base.. only way i can see that working, and then you have use of trig or pythagoras. Though not sure that's what your program allows?
 
Ok.

We assume we're in Euclidean geometry and that the base of the triangle (the magnitude of which is known) lies on the X axis. Where is unimportant.

Also, we know by the definition of a triangle that the vertex that does not lie on the X axis forms the furthest point in the triangle from the base. This distance is denoted by the height which we are given.

Next, we bisect this triangle with the line extending from this high vertex to the base which is perpendicular to the X-axis.

We notice we have 2 right triangles each with a side of length h (the height of the original triangle), and we know the sum of the bases of these two triangles is equal to b (the measure of the base of the original triangle).

We know that the measure of the third side of the first triangle (the one on the left, tending towards negative X values), is equal to sqrt( h^2 + b1^2 ), where b1 is the base of this left triangle (b1 + b2 = b). We also know that the other unknown side, in the right triangle is equal to sqrt( h^2 + b2^2 ).

Now that we can compute the perimeter:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b2^2)

we can maximize this.

WLOG, let b1 be the unknown and let b2 = b - b1.

So we then have:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b^2 -2b*b1 + b1^2)



Due to the properties of triangles, and for some reasons I don't feel like proving, we know that the perimeter will be maximal when the triangle in question is a right triangle, and due to the fact that we'll have a symmetry about b/2, the range is found by the equation in the following picture:

Blufner - [VB6]Help with mathmatical coding. - RaGEZONE Forums


Use those formulas to compute the minimum and maximum perimeters given height & base width.

That is:

min = b + h + sqrt(b^2 + h^2)
max = b + 2*sqrt(h^2 + (b/2)^2)

Magics.
 
Last edited:
Hai mate ^^

You could do this assuming that you can specify the type of triangle (therefore you know the angles in said triangle), and you would have to be able to assume that the point of the triangle was in the center of the base.. only way i can see that working, and then you have use of trig or pythagoras. Though not sure that's what your program allows?
We are only allowed to use what the user inputs, which is the base and height only.

Ok.

We assume we're in Euclidean geometry and that the base of the triangle (the magnitude of which is known) lies on the X axis. Where is unimportant.

Also, we know by the definition of a triangle that the vertex that does not lie on the X axis forms the furthest point in the triangle from the base. This distance is denoted by the height which we are given.

Next, we bisect this triangle with the line extending from this high vertex to the base which is perpendicular to the X-axis.

We notice we have 2 right triangles each with a side of length h (the height of the original triangle), and we know the sum of the bases of these two triangles is equal to b (the measure of the base of the original triangle).

We know that the measure of the third side of the first triangle (the one on the left, tending towards negative X values), is equal to sqrt( h^2 + b1^2 ), where b1 is the base of this left triangle (b1 + b2 = b). We also know that the other unknown side, in the right triangle is equal to sqrt( h^2 + b2^2 ).

Now that we can compute the perimeter:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b2^2)

we can maximize this.

WLOG, let b1 be the unknown and let b2 = b - b1.

So we then have:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b^2 -2b*b1 + b1^2)



Due to the properties of triangles, and for some reasons I don't feel like proving, we know that the perimeter will be maximal when the triangle in question is a right triangle, and due to the fact that we'll have a symmetry about b/2, the range is found by the equation in the following picture:



Use those formulas to compute the minimum and maximum perimeters given height & base width.

That is:

min = b + h + sqrt(b^2 + h^2)
max = b + 2*sqrt(h^2 + (b/2)^2)

Magics.

Thank you very much for taking the time to do this. I learned something new XD

I will incorporate this into my code.
 
Ok.

We assume we're in Euclidean geometry and that the base of the triangle (the magnitude of which is known) lies on the X axis. Where is unimportant.

Also, we know by the definition of a triangle that the vertex that does not lie on the X axis forms the furthest point in the triangle from the base. This distance is denoted by the height which we are given.

Next, we bisect this triangle with the line extending from this high vertex to the base which is perpendicular to the X-axis.

We notice we have 2 right triangles each with a side of length h (the height of the original triangle), and we know the sum of the bases of these two triangles is equal to b (the measure of the base of the original triangle).

We know that the measure of the third side of the first triangle (the one on the left, tending towards negative X values), is equal to sqrt( h^2 + b1^2 ), where b1 is the base of this left triangle (b1 + b2 = b). We also know that the other unknown side, in the right triangle is equal to sqrt( h^2 + b2^2 ).

Now that we can compute the perimeter:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b2^2)

we can maximize this.

WLOG, let b1 be the unknown and let b2 = b - b1.

So we then have:
b + sqrt(h^2 + b1^2) + sqrt(h^2 + b^2 -2b*b1 + b1^2)



Due to the properties of triangles, and for some reasons I don't feel like proving, we know that the perimeter will be maximal when the triangle in question is a right triangle, and due to the fact that we'll have a symmetry about b/2, the range is found by the equation in the following picture:

Blufner - [VB6]Help with mathmatical coding. - RaGEZONE Forums


Use those formulas to compute the minimum and maximum perimeters given height & base width.

That is:

min = b + h + sqrt(b^2 + h^2)
max = b + 2*sqrt(h^2 + (b/2)^2)

Magics.

Count me as a fan :ott: !!
 
And that was pythagoras supplied by jMerlin , as i had said previously :P I did give you two options to follow , and what do you know one of them was right without need of extra input :thumbup1:
 
Back