SRL Archive - SRL Archives

math.scar, and MMVector


Awkwardsaw

2009-07-16 00:19:44

i had fun making these, although they may not be usefull for rs scripts.

{*******************************************************************************
function TriAngType(a, b, c: extended): string;
By: akwardsaw
Description: it checks what type of triangle it is. based off of the SIDE MEASURES
*******************************************************************************}
function TriAngType(a, b, c: extended): string;
begin
if a + b <= c then
begin
writeln('Wrong Triangle side measures');
exit;
end;
if Sqr(a) + sqr(b) < sqr(c) then result:= 'acute';
if Sqr(a) + sqr(b) = sqr(c) then result:= 'right';
if Sqr(a) + sqr(b) > sqr(c) then result:= 'acute';
end;

{*******************************************************************************
function RightTriSideMeasure(a, b, c: extended; sidetosolve: string): extended;
By: akwardsaw
Description: it solves for a side of a right triangle. leave the side you dont know to what ever
you want. showword = true if you want to show the work.
*******************************************************************************}
function RightTriSideMeasure(a, b, c: extended; sidetosolve: string; showwork: boolean): extended;
begin
case lowercase(sidetosolve) of
'a': begin
if showwork then
begin
writeln(floattostr(c) + '^2 = ' + floattostr(b) + '^2 + a^2');
writeln(floattostr(Sqr(c)) + ' = ' + floattostr(Sqr(b)) + ' + a^2');
writeln(floattostr(Sqr(c) - Sqr(b)) + ' = a^2');
writeln(floattostr(sqrt((Sqr(c)) - (sqr(b)))) + ' = a');
end;
result:= sqrt((Sqr(c)) - (sqr(b)));
end;
'b': begin
if showwork then
begin
writeln(floattostr(c) + '^2 = b^2 + ' + floattostr(a) + '^2');
writeln(floattostr(Sqr(c)) + ' = b^2 + ' + floattostr(Sqr(a)));
writeln(floattostr(Sqr(c) - Sqr(a)) + ' = b^2');
writeln(floattostr(sqrt((Sqr(c)) - (sqr(a)))) + ' = b');
end;
result:= sqrt((Sqr(c)) - (sqr(a)));
end;
'c': begin
if showwork then
begin
writeln('c^2 = ' + floattostr(b) + '^2 + ' + floattostr(a) + '^2');
writeln('c^2 = ' + floattostr(sqr(b)) + ' + ' + floattostr(sqr(a)));
writeln('c^2 = ' + floattostr(sqr(b) + sqr(a)));
writeln('c = ' + floattostr(sqrt(Sqr(a) + sqr(b))));
end;
result:= sqrt(Sqr(a) + sqr(b));
end;
end;
end;

{*******************************************************************************
procedure GetVector(x1, y1, x2, y2: integer; var rise, run: integer);
By: akwardsaw
Description: it simply finds the vector for 2 points. stores the x as run, y as rise
*******************************************************************************}
procedure GetVector(x1, y1, x2, y2: integer; var rise, run: integer);
begin
rise:= x2-x1;
run:= y2-y1;
end;

{*******************************************************************************
function Issimilier(av1, av2, bv1, bv2: extended; var ratio: extended):boolean;
By: akwardsaw
Description: it finds out if two sets of ratios are similer. if true ratio returns
the ratio.
*******************************************************************************}
function Issimilier(av1, av2, bv1, bv2: extended; var ratio: extended):boolean;
var val1, val2: extended;
begin
val1:= av1 / av2;
val2:= bv1 / bv2;
if val1 = val2 then
begin
ratio:= val1;
result:= true;
end;
end;

{*******************************************************************************
procedure MMVector(vector : tpointarray; rx, ry: integer);
By: akwardsaw
Description: it moves the mouse using a set vector, in a Tpoint array
*******************************************************************************}
procedure MMVector(vector : tpointarray; rx, ry: integer);
var v, x, y: integer;
begin
for v:= 0 to high(vector) do
begin
getmousepos(x, y);
mmouse(x + vector[v].x, y + vector[v].y, rx, ry);
end;
end;

[minitut]
vectors! you may not know what they are, but this what this tut is for :)

a vector, is literally the distance of a direct path, caused by a transition. lets say your mouse is at coord (100, 100) and you move your mouse to (150, 300). your mouse had a vector or <50, 200> because your mouse moved 50 points on the x axis, and 200 points on the y axis. makes sence?
[/minitut]

how you would use MMVector:


vector:= [point(100, 100), point(-100, -100), point(200, 200), point(-200, -200)];
MMVector(vector, 5, 5);

that example shows, that your mouse will move 100 points down and over, and 100 points up and over. then 200 points down and over, ect ect. NOT to cord 100, 100, then go to coord -100, 100 (unless your mouse pos was at 0, 0 of course)

enjoy :D

Da 0wner

2009-07-16 00:39:39

program New;

var
x, y, xx, yy : integer;

begin
MoveMouse(100, 100);
GetMousePos(x, y);
MoveMouse(150, 300);
GetMousePos(xx, yy);
Writeln(Format('Vector = <%d, %d>', [xx - x, yy - y]));
end.
?

Awkwardsaw

2009-07-16 00:46:46

thats not fun though :p and its a lot more detectable. besides, thats not vector moving

Da 0wner

2009-07-16 00:49:44

Explain more clearly then :(.

It returned what you said xD.

Awkwardsaw

2009-07-16 01:00:48

ok, so. first off you must know about slope, and the coord plane and stuff.

then you need to know about transitions( a form of a transformation ).

a vector, is pretty much the slope of a transition, but it is called differently, which is <xmod, ymod>. the xmod states the movement on the x axis. lets say the xmod is 100. from the current point, it will transition 100 points over on the x axis. the same with the ymod, exept it goes up and down :p

how you use vectors is something like:

the vector of (50, 50) to (100, 100) was <50, 50>.

OR something like, the new point of (50, 50) with a vector of <50, 50> is (100, 100)

are you getting it now? :p its hard to explain without a diagram.. just play around with the procedure pl0x

Da 0wner

2009-07-16 01:03:15

-.-, again, my function returned what you said :p.

Except it doesn't add vectors or whatever, just returns them :p.

Awkwardsaw

2009-07-16 01:06:51

ok. try this out:


mmouse(100, 100, 0, 0);
MMVector([point(25, 25), point(75, 50), point(-100, -75)], 5, 5);

what it should do, is go to point 100, go down and over 25, go over 75 and down 50, then go over 100, and go back up 75,

marpis

2009-07-19 16:41:57

Your 'vector moving' is moving mouse between points with randomness, thats an easy task done in a hard way.

caused

2009-07-19 16:47:18

I've got to admit that Vector Moving is a cool idea : D… I wouldnt use SRL functions for that though.

Awkwardsaw

2009-07-19 18:11:53

From: marpis
Your 'vector moving' is moving mouse between points with randomness, thats an easy task done in a hard way.


it actually made it easier. instead of having multiple lines of mm, its all put into an array, that, and it doesn't move it to a specific coord, and that's the point of it :p

MylesMadness

2009-07-19 18:25:30

Why would this be useful in runescape?

Awkwardsaw

2009-07-19 20:53:11

iunno. i guess it could be edited to find an uptext, or something in the inventory :p

other than that, to make custom mouse paths

marpis

2009-07-19 21:26:08

From: Awkwardsaw
it actually made it easier. instead of having multiple lines of mm, its all put into an array, that, and it doesn't move it to a specific coord, and that's the point of it :p


i prefer readability

Awkwardsaw

2009-07-19 23:20:45

are you talking about the procedure or using it?

Blender

2009-07-20 04:08:16

I really don't see a use for vectors in SRL.

A new Mouse() function on the other hand would be awesome…

Awkwardsaw

2009-07-20 04:17:10

like what do you have in mind?