Solved

how to get points to expand a triangle

Posted on 2014-11-18
14
108 Views
Last Modified: 2014-12-01
Dear Experts

I expect there is a straight forward formula for this, but I cannot find it.

In my VB6 app, I have defined a right triangle and the coordinates of the vortices are known.
The right angle of this triangle is in the lower left of the triangle.

I need to get the area of an expanded version of this triangle - expanded equally on all sides by 60 points (pixels in my app).

I have the area formula working well. Where I need help is how to find the points of the expanded triangle.
I can alter the x,y of the right angel easily enough; but am lacking the formula of how to find the y (for height) and x (for base). High School math is failing me,

Thanks
klheitz
0
Comment
Question by:klheitz
  • 5
  • 3
  • 2
  • +4
14 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40450962
You can't expand all sides by 60 points and still maintain a right triangle unless I'm missing something.


"A^2 + B^2 = C^2" ~ Pythagoras
0
 

Author Comment

by:klheitz
ID: 40451017
Thanks Kyle;
I attached a picture of what I'm attempting to do. It may help clarify.
The Yellow triangle is known xys; lower left corner of red/green triangle would be known.
Does this help?

Thanks
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 40451051
@klheitz, I don't see the attachment.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:klheitz
ID: 40451055
Thank you. I'll try again.
attached (hopefully)
expanded-triangle.png
0
 
LVL 17
ID: 40451267
Where is the 60 pixel measured? Is that the perpendicular distance between the sides?
0
 
LVL 84

Expert Comment

by:ozo
ID: 40451329
For points laid out as
X0,Y1


          x0,y1


          x0,y0    x1,y0

X0,Y0                                  X1,Y0

the X,Y points of the outer triangle can be derived from the x,y points of the inner triangle by

X0=x0-60
Y0=y0-60
X1=x1+60*((x1-x0)/(y1-y0)+sqrt(1+((x1-x0)/(y1-y0))^2))
Y1=y1+60*((y1-y0)/(x1-x0)+sqrt(1+((y1-y0)/(x1-x0))^2))
0
 
LVL 32

Expert Comment

by:Paul Sauvé
ID: 40451347
You have the vertices, so simply multiply the length of each side (horizontal and vertical) by the same value (say 1.25, 1.6, ...) rather than ADDING the same value to the 2 sides.

This will give you a larger size triangle with EXACTLY the same proportions.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 40452661
Agreed with Paul.  

The lengths can be scaled by a factor . . . but I wouldn't go messing with the proportions.


eg:

Right triangle of 300, 400, 500.  

You can't just "-60" from all sides, but you could take away 20% (or multiply by .8) from each length to give you
240, 320, 400

From my understanding of what you're trying to do is take the yellow triangle, and based on a new point in the red triangle, (the point being the corner where the 2 sides meet) scale the triangle to be that size.

If that's the case -  you can measure the distance need to grow by taking a delta of yellow and red

So:
Let yellow be X,Y points.  
Let Red be A,B points (A,B replacing X&Y for clearer communication):

'how far did the triangle move to the left?
Dim percentage as Decimal = CFloat(X1 - A0) /(X1 - X0)    'Convert the top number to a float so it stays a float.
'EG:  240 / 300 =  .8

A1 = (X1-X0) * percentage  'scale X
B1 = (Y1 - Y0) * percentage 'scale Y
0
 

Author Comment

by:klheitz
ID: 40452993
Hi All;
Thank you for these responses. I spent some time w/ the formulas to alter the points and wasn't able to get to the correct results - I will change my approach to line length and percentage.
I will be working on this again tomorrow morning.
Thank you again
0
 
LVL 16

Expert Comment

by:dhsindy
ID: 40462953
Note: Your two triangles have parallel sides therefore equal angles.  They are like  magnifications of each other.  All linear measures have the same ratio.  You have three sides A, B, and C.  

Say you want to add 60 to A1, find a ratio A1+60/A1 = R, then B2 = (B1)R, and C2 = (C1)R.  For example take standard 3, 4, 5 triangle.  60+3/3=R; then, B2=4(60+3/3, and C2=5(60+3/3).  The B2 sides would be 63, 84, 105.  Verify by using A^2+B^2=C^2.
Substituting, 63^2+84^2=105^2

This works for linear distances but not areas because the area is expanding in two dimensions not just one.
0
 
LVL 84

Expert Comment

by:ozo
ID: 40463554
If you want the perpendicular distance between the sides of the original and expanded triangles to be 60, as Eamon Norseven construed, then the factor you'd need to scale by would be
1 + 60*(1/(y1-y0) + 1/(x1-x0) + sqrt(1/(y1-y0)^2 + 1/(x1-x0)^2))
which is what you would get from altering the points according to the formulas in http:#a40451329
Are those the formulas you spent some time with?  If so, in what way were what you were able to get not the correct results?
0
 

Author Comment

by:klheitz
ID: 40465767
Hi ozo;

Using these formulas in this order:
1. X0=x0-60
2. Y0=y0-60
3. X1=x1+60*((x1-x0)/(y1-y0)+sqrt(1+((x1-x0)/(y1-y0))^2))
4. Y1=y1+60*((y1-y0)/(x1-x0)+sqrt(1+((y1-y0)/(x1-x0))^2))

One thing that is probably throwing them off, is my y-axis is ascending (eg; y1 is < y0).
To compensate I changed
      y0 = y0-60 -- to -- y0 =  y0+60; and
      y1= y1 + 60 * ((y1 - y0) / (x1 - x0) + Sqr(1 + ((y1 - y0) / (x1 - x0)) ^ 2)) -- to --
      y1= y1 - 60 * ((y1 - y0) / (x1 - x0) + Sqr(1 + ((y1 - y0) / (x1 - x0)) ^ 2))

Attached is a png (1.png) of what I'm getting when I use the formulas in this order.
Note I fed x0,y0,y1 into the formulas after they were altered.

Before the 4-lines of code above: x0=1605//y0=3420//x1=2170//y1= 2600
After: x0=1545//y0=3480//x1=2201//y1= 2580

You'll see x1 and y1 don't extend far enough.

So I tried feeding in non-altered values for x0,y0,y1 and I get (2.png attached):
Orig values: x0=1605//y0=3420//x1=2170//y1= 2600
After formula values (x0New, y0New, x1New, y1New):
x0new=1545//y0new=3480//x1new=2202//y1new= 2581

The difference between the two is very small (see x1 in first example vs. x1new in 2nd)

Do you think this is all due to the reversal of the y-axis?
Thanks in advance
klheitz
1.png
2.png
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40468319
Reversing y
X1=x1+60*((x1-x0)/(-y1--y0)+sqrt(1+((x1-x0)/(-y1--y0))^2))
-Y1=-y1+60*((-y1--y0)/(x1-x0)+sqrt(1+((-y1--y0)/(x1-x0))^2))
X0=x0-60
-Y0=-y0-60
simplifying
Y1=y1-60*((y0-y1)/(x1-x0)+sqrt(1+((y0-y1)/(x1-x0))^2))
X1=x1+60*((x1-x0)/(y0-y1)+sqrt(1+((x1-x0)/(y0-y1))^2))
Y0=y0+60
X0=x0-60


Orig values: x0=1605//y0=3420//x1=2170//y1= 2600
After formula values
X0=1545//Y0=3480//X1=2284.205//Y1=2407.171
0
 

Author Closing Comment

by:klheitz
ID: 40474938
Thank you ozo! This works perfectly.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question