# Triangle Calculations to get all possible permutations

Hello,
I am trying to calculate all possible permutations with a function.
I have 100 numbers for each of the 3 products example

``````>network speed
1.2354
1.2885
1.3569

>network latency
0.263
0.214
0.325

>duration
5.323
6.525
4.784
etc..
``````

if I wanted to get all combinations together I would have to do 100*100*100 = 1,000,000
what would be the best approach for speed and stability ?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Database and Application DeveloperCommented:
Assuming you have a loop with access to three point for each triangle:

Single aX = 0;
Single aY= 0;
Single bX = 3;
Single bY = 4;
Single cX = 0;
Single cY = 4;

Single base = findBase(aX, aY, bX, bY);
Single height = findBase(aX, aY, bX, bY, cX, cY);

Single area = (base * height)/2.0;
.
.
private single findBase(aX, aY, bX, bY)
{
single b = ((aX-bX)^2 + (aY-bY)^2)^.05;
return b;
}

I will post findBase() function shortly.

Mike
0
Database and Application DeveloperCommented:
This is the tested solution and it works.
``````        private void button1_Click(object sender, EventArgs e)
{
Single aX = 0;
Single aY= 0;
Single bX = 3;
Single bY = 4;
Single cX = 0;
Single cY = 4;

Single b =findBase(aX, aY, bX, bY);

Single height = findHeight(aX, aY, bX, bY, cX, cY);

Single area = (Single)((b * height) / 2.0);
MessageBox.Show(area.ToString());
}
private Single findBase(Single aX, Single aY, Single bX, Single bY)
{
return (Single)Math.Pow((Math.Pow((aX - bX), 2.0) + Math.Pow((aY - bY), 2.0)), 0.5);
}
private Single findHeight(Single aX, Single aY, Single bX, Single bY, Single cX, Single cY)
{
Single m1 = (Single)(aY - bY) / (Single)(aX - bX);
Single m2 = -(1/m1);
Single hX = (m1*aX- m2*cX + cY - aY)/(m1-m2);
Single hY = m1*hX - m1 * aX + aY;

return (Single)Math.Pow((Math.Pow((cX - hX), 2.0) + Math.Pow((cY - hY), 2.0)), 0.5);
}
``````
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Database and Application DeveloperCommented:
I just noticed; you were not looking for triangle area I guess. The question was not very clear so you got the solution possibly with no use for you. If so, consider deleting it and posting it again with some clear description.

Thanks,

Mike
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.