SRL Archive - Other Scripts

Pythagorean's Theorem Solver


Neonknight77

2006-03-03 20:48:33

Here is a little thing I made to help me in math.

Sdcit

2006-03-03 21:23:04

NICE! hm… make a,b a extended?

Neonknight77

2006-03-03 21:27:17

For what??

Mutant Squirrle

2006-03-03 22:04:28

a and b really needed?

BenLand100

2006-03-04 01:11:59

Now you gotta make a full blown triangle solver :)

Jag024

2006-03-09 17:26:19

This is great, even thought in most of my classes we have to show our work.

Cheesehunk

2006-03-09 19:25:44

Hmmm, the script doesn't show up for me??

The link is missing, I would love to get a hold of this!

Thanks,
Cheesehunk.

Incebrot

2007-03-15 13:23:57

Edit by Star: Bye Bot

Avaphi

2007-03-15 14:59:54

Uhm… Neon is a friend of mine… I got it somewhere… There we go… Its attached to my post.

tarajunky

2007-03-15 15:17:03

Methinks Incebrot is a bot…

Somebody whip out the ban stick, lol

Ruroken

2007-03-15 16:49:45

From: tarajunky
Methinks Incebrot is a bot…

Somebody whip out the ban stick, lol


hehehe.

@Ben : Yeah, now he does. I might even do it :)

Ron

2007-03-15 17:32:57

Cool program and pretty simple.

a² + b² = c²

Here are some quick functions to FindA, FindB, and FindC. :)


{
Checks if the functions work using this triangle.

|\
| \
A = 3 | \ C = 5
| \
|____\
B = 4

By Ron :D
}

program PythagoreanFunctionsByRon;

const
SideA = 3;
SideB = 4;
SideC = 5;

// FindA - Finds side A using pythagorean's theorem.
// By Ron :)
function FindA(SideB, SideC : Extended) : Extended;
begin
Result := Sqrt(pow(SideC, 2) - pow(SideB, 2));
end;

// FindB - Finds side B using pythagorean's theorem.
// By Ron :)
function FindB(SideA, SideC : Extended) : Extended;
begin
Result := Sqrt(pow(SideC, 2) - pow(SideA, 2));
end;

// FindC - Finds side C using pythagorean's theorem.
// By Ron :)
function FindC(SideA, SideB : Extended) : Extended;
begin
Result := Sqrt(pow(SideA, 2) + pow(SideB, 2));
end;

begin
ClearDebug;
WriteLn('Side A = ' + FloatToStr(FindA(SideB, SideC)) + ' if... Side B = ' + FloatToStr(SideB) + ' | Side C = ' + FloatToStr(SideC));
WriteLn('Side B = ' + FloatToStr(FindB(SideA, SideC)) + ' if... Side A = ' + FloatToStr(SideA) + ' | Side C = ' + FloatToStr(SideC));
WriteLn('Side C = ' + FloatToStr(FindC(SideA, SideB)) + ' if... Side A = ' + FloatToStr(SideA) + ' | Side B = ' + FloatToStr(SideB));
end.

~Ron

TOB

2007-03-15 19:01:33

Ron, one function is easier xD

function Pythagorean(SideA, SideB, SideC : Extended; SolveFor: string): Extended;
begin
if(Lowercase(SolveFor) = 'a') then
Result := Sqrt(pow(SideC, 2) - pow(SideB, 2));
else if(Lowercase(SolveFor) = 'b') then
Result := Sqrt(pow(SideC, 2) - pow(SideA, 2));
else if(Lowercase(SolveFor) = 'c') then
Result := Sqrt(pow(SideA, 2) + pow(SideB, 2));
end;

Yakman

2007-03-16 16:51:11

how about something that looks like this?


procedure Pythag(var a,b,c:extended);
begin
if(a<>0)and(b<>0)and(c<>0)then
Exit;
if(a=0)then
begin
a= Sqrt( (c*c) - (b*b) );
end else
if(b=0)then
begin
a= Sqrt( (c*c) - (a*a) );
end else
if(c=0)then
begin
a= Sqrt( (a*a) + (b*b) );
end
end;

the procedure finds which is 0, then uses the other two to solve it

Ciadipexo

2007-03-18 05:31:15

Edit by Star: Bye bot

Sumilion

2007-03-18 08:52:48

Whats up with all these bots visiting SRL ?