Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to get points to expand a triangle

Posted on 2014-11-18
14
107 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the Difference between Percentile and T-Score, where to use which one ? 5 166
SLMGR Switches Are Not Working On KMS Host 3 109
MsgBox 4 68
Most Consistent Performer 4 34
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

808 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