SRL Archive - Research & Development Lounge

Two Math Functions I made.


Sandstorm

2009-01-11 14:26:36

I actually made these because I didn't feel like doing my own homework, but yea xD.

Pythagorean's theorom:

Program New;

Function Pythag(X, Y : Integer; C : Boolean) : Extended;
Begin
Case C Of
False : Result := Sqrt((X*X) + (Y*Y));
True : Result := Sqrt((Y*Y) - (X*X));
End;
End;

Begin
WriteLn(FloatToStr(Pythag(40, 50, true)));
End.

X and Y are the two numbers your supplied. C is whether you want to find C or Not.

Slope:

Program New;

Function Slope(x1, y1, x2, y2 : Integer) : String;
Var
X3, Y3 : Integer;
begin
X3 := X1 - X2;
Y3 := Y1 - Y2;
Result := IntToStr(Y3) + '/' + IntToStr(X3);
WriteLN(Result);
end;

Begin
Slope(strtoint(ReadLn('What is X1?')), strtoint(ReadLn('What is Y1?')), strtoint(ReadLn('What is X2?')), strtoint(ReadLn('What is Y2?')));
End.

Obvious. It actually asks the questions backwards for some reason xD.

I don't know if these have already been made, but I figured I'd post them in case anyone wanted them.

~Sandstorm

NCDS

2009-01-11 15:11:59

lol 10th grade math?

ian.

2009-01-11 15:12:36

8th grade >.>

noidea

2009-01-11 15:19:44

From: 99_
8th grade >.>

Nope, Im in 8th and idk what sqrt is.

ian.

2009-01-11 15:23:54

square root..

noidea

2009-01-11 15:24:55

From: 99_
square root..


Oh, then nvm.

ian.

2009-01-11 15:25:09

:p

Sandstorm

2009-01-11 15:29:48

From: N C D S
lol 10th grade math?


I dunno. I'm doing the 8th grade, even though I should be doing like 9th/10th :/.

I recently moved to the US, so I have to re-take ALL the essential classes, despite me having passed them already >.<. I just decided I CBF to do it again, so I made my own functions xD.

~Sandstorm

Buckleyindahouse

2009-01-11 15:34:33

Thats 8th grade math lol, slope is 10th grade math. Try making something that makes Sin Cos and Tan cuz this shit is annoying atm.

Sandstorm

2009-01-11 15:36:46

From: Buckleyindahouse
Thats 8th grade math lol, slope is 10th grade math. Try making something that makes Sin Cos and Tan cuz this shit is annoying atm.


Is there a specific formula for it? If so, pm me it and a sample problem or two with the answers, so I can verify it works.

~Sandstorm

ian.

2009-01-11 15:43:52

sin cos tan is trig.. you can look it up :P

Sandstorm

2009-01-11 15:46:35

I know it's Trig, I just don't know anything past that xD.

Yea, I'll look it up.

~Sandstorm

NCDS

2009-01-11 15:53:00

From: Buckleyindahouse
Thats 8th grade math lol, slope is 10th grade math. Try making something that makes Sin Cos and Tan cuz this shit is annoying atm.


Yeah thats what I thought.
I havent taken Math in so long :redface:

ian.

2009-01-11 15:56:55

slope is 6th grade math :\

Sandstorm

2009-01-11 16:00:23

Mmm, slope is like 9th or 10th in Canada I believe, but I'm in the US now :o.

~Sandstorm

Baked0420

2009-01-11 16:01:23

yea slope is definitely not 10th grade math, I'm in 11th grade (taking Alg. II/Trig.), last year I had Geometry. We did do slopes but I actually learned how to do slopes before 10th, I learned SIN COS and TAN in 10th, Geometry, I wonder why I learned it then and not now in Trig. like 99_ said.

Buckleyindahouse

2009-01-11 16:11:36

I got geometry honors so we learned slope first semester now we doing the tan,cos,sin. i dont remember what the hell i learned in 6th grade math, but w/e it was i prolly failed it lmfao.

Naum

2009-01-11 16:24:20

There is a function called Hypot in SCAR :)

Sandstorm

2009-01-11 16:30:42

Lol, didn't know that ^.^.

Ah well.

~Sandstorm

Baked0420

2009-01-11 17:29:34

From: Buckleyindahouse
I got geometry honors so we learned slope first semester now we doing the tan,cos,sin. i dont remember what the hell i learned in 6th grade math, but w/e it was i prolly failed it lmfao.


I had geometry honors also, now I'm in honors for Alg II/Trig. And I'm pretty sure I also learned TAN, COS, SIN at least after half the year also, I did really really well last year, but I totally forgot how I used SIN, COS, and TAN I forget what we used it for and how we used them, but it doesn't matter to much because I don't ever use them today, just last year in school.

senrath

2009-01-11 18:07:45

For Sin, Tan, and Cos the formulas are:
sin(theta) = opposite side length/hypotenuse
cos(theta) = adjacent side length/hypotenuse
tan(theta) = opposite side length/adjacent side length

droppeD:)

2009-01-15 00:18:16

From: Buckleyindahouse
Thats 8th grade math lol, slope is 10th grade math. Try making something that makes Sin Cos and Tan cuz this shit is annoying atm.


lol i'm gonna have to agree with you there

mormonman

2009-01-15 00:22:12

From: senrath
For Sin, Tan, and Cos the formulas are:
sin(theta) = opposite side length/hypotenuse
cos(theta) = adjacent side length/hypotenuse
tan(theta) = opposite side length/adjacent side length


csc(theta) = hypo/opposite (1/sin[theta])
sec(theta) = hypo/adjacent (1/cos[theta])
cot(theta) = adjacent/opposite (1/tan[theta])
… not that useful imho but there are some more trig functions

Nava2

2009-01-15 08:30:02

Slope is grade nine.

But, pythag is the same as the Dist function. Or distance I forget :p

ZaSz

2009-01-15 08:39:03

I made a script, where you could enter 2 cord. Then it gets slope (like u got). Or 1 cord and rate, and gets what ever. I forgot it all already.

marpis

2009-01-18 16:47:45

make it calculate side or cornerangle by using this

x/sin(a) = y/sin(b)

where x and y are sides of the triangle, and a is the corner that x "faces".
b is the corner that y "faces" like this

[PHP]
.
. .
. a .
. .
y . .
. b .
´ ´ ´ ´ ´ ´ ´ ´
x
[/PHP]

none of the corners have to be 90, so its quite useful in geometry.
In finnish this is called "sin-lause" (sin-sentence?).
There is also even better thing called "cosini-lause" ("cos-sentence?") but i dont remember it anymore.

Sandstorm

2009-01-18 17:32:05

I've got a suggestion for finding angle ^.^.

Protractor!!!

Sorry, I had to.

Anyways, can you post a sample problem? I generally like to reverse engineer things. I looked into Cos and couldn't think of a way to do find it, unless Cosine has some hidden fixed value.

~Sandstorm

Santa_Clause

2009-01-19 06:03:53

From: marpis
make it calculate side or cornerangle by using this

x/sin(a) = y/sin(b)

where x and y are sides of the triangle, and a is the corner that x "faces".
b is the corner that y "faces" like this

[PHP]
.
. .
. a .
. .
y . .
. b .
´ ´ ´ ´ ´ ´ ´ ´
x
[/PHP]

none of the corners have to be 90, so its quite useful in geometry.
In finnish this is called "sin-lause" (sin-sentence?).
There is also even better thing called "cosini-lause" ("cos-sentence?") but i dont remember it anymore.


Sine-rule and Cosine-rule.

JuKKa

2009-01-19 07:29:34

I kinda just skipped through math from 7th to 9th grade, geometry and alike are all gibberish to me :)

Im doing quite well in math otherwice..

Simtoon

2009-01-20 00:40:37

instead of putting the numbers in can u just make a form so u can put the no. in then bang!

n3ss3s

2009-01-21 10:52:20

Most of trigonometric functions have few applications in scripting, unless you have a plan on an epic shape recognition function, or some sort of a game, or scripting in another game than RuneScape…

However if you like to work on something, don't touch circles, it's all been made before.


You could try applying the sine law (but no cosine law, since computer can always form a right triangle) if you have a use for it in mind.