the math plugin download doesn't exist

Started by Kingzjester, Mon 29/03/2004 16:56:58

Previous topic - Next topic

Kingzjester

... and I sortof need it. Oh, and if you know, can it handle tan^-1? There is an absurd path calculation puzzle that I need to, er, calculate for that game of mine. I could concievably make a small program in C that would generate a table of all the possible results and fit it into an if-else if-else if-else if argument from hell that I could then just cut&paste into the global script, but that would be too memory intensive and ungodly-looking.

BTW, you have to admit that my problems and questions have evolved from not noticing that whole chunks of code have been edited out into a far more subtler areas.

Scummbuddy

Yes, we know that Erica has gone missing, as well as her websites and downloads.

right now the account webpage is frozen, but you can check back later, or if someone else gives you a better link, but this is a page that houses the plug in.

http://www.freewebs.com/skimbleshanks/index.htm
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Kingzjester

#2
Drat and double drat!

Can somebody by any chance e-mail me the dll?

Kweepa

#3
Here's a dll that should work for you.
Download here.

Use

int ints_to_float(int units, int thousandths);
int atan(int radians);
int fmul(int a, int b);
int float_to_int(int floatingPointNumber);

Here's the full list of functions:
Ã, "import int GetTextExtentX(int font, string text);
"
Ã, "import int GetTextExtentY(int font, string text);
"
Ã, "import int int_to_float(int a);
"
Ã, "import int ints_to_float(int units, int thousandths);
"
Ã, "import int float_to_int(int a);
"
Ã, "import int fadd(int a, int b);
"
Ã, "import int fsub(int a, int b);
"
Ã, "import int fmul(int a, int b);
"
Ã, "import int fdiv(int a, int b);
"
Ã, "import int fneg(int a);
"
Ã, "import int fabs(int a);
"
Ã, "import int fcomp(int a, int b);
"
Ã, "import int fgreater(int a, int b);
"
Ã, "import int fless(int a, int b);
"
Ã, "import int sin(int a);
"
Ã, "import int cos(int a);
"
Ã, "import int tan(int a);
"
Ã, "import int asin(int a);
"
Ã, "import int acos(int a);
"
Ã, "import int atan(int a);
"
Ã, "import int atan2(int y, int x);
"
Ã, "import int exp(int a);
"
Ã, "import int log(int a);
"
Ã, "import int pow(int a, int b);
"
Ã, "import int sqrt(int a);
"
Ã, "import int pi();
"

EDIT: As I recall, the old math dll didn't have atan (tan^-1)...
Still waiting for Purity of the Surf II

Kingzjester

Oh, hey, thanks! Lemme see if I get this straight:

int ints_to_float(int units, int thousandths);

If units = 23 and thousandths = 567 the whole function would gimme = 23.567? How does it then still stay an integer? And if I give it 23 and 1000 respectively, will it = 24? What kind of voodoo is this? Hmm... perhaps it is just a fake floating point number that I could forge on my own by multiplying all my relevant numbers by a 1000 (which I could also fuck up royally by forgetting to divide later on)....

Does float_to_int rounds up or down discriminantly?

What does fcomp(int a, int b); return? I assume it s a bool checking if variables are equal, and I could concievably give it a test run - but hey - who has time nowadays?!

How many decimals does pi() run?

So, I figure I have answered most of my important questions here, feel free to correct me.

Kweepa

Quote
If units = 23 and thousandths = 567 the whole function would gimme = 23.567?

Correct.

Quote
How does it then still stay an integer? And if I give it 23 and 1000 respectively, will it = 24?

Yup.

Quote
What kind of voodoo is this? Hmm... perhaps it is just a fake floating point number that I could forge on my own by multiplying all my relevant numbers by a 1000 (which I could also fuck up royally by forgetting to divide later on)....

No, it uses the same technique as the old math plugin - a processor low precision floating point number stored in the int, which will look like garbage if you try to use it as an int.

Quote
Does float_to_int rounds up or down discriminantly?

Always down. I recommend this to round to nearest (assuming positive):

// add 0.5, then convert to int
int integerNearest = float_to_int(fadd(floatingPointValue, ints_to_float(0, 500)));

Or, you could do this:
int ival = float_to_int(fmul(fval, int_to_float(1000)));
int units = ival/1000;
int thousandths - ival%1000;

Quote
What does fcomp(int a, int b); return? I assume it s a bool checking if variables are equal, and I could concievably give it a test run - but hey - who has time nowadays?!

That's the same as the old math plugin for backward compatibility.
a < b, returns -1
a == b, returns 0
a > b, returns 1

Quote
How many decimals does pi() run?

About seven I think - the accuracy of 32 bit FP numbers.

Steve
Still waiting for Purity of the Surf II

Kingzjester

Heh, refering to the old math plugin really means nothing to me since I never played around with it.

Quote...a processor low precision floating point number stored in the int, which will look like garbage if you try to use it as an int.
Hmmm.... That makes more sense than my shoestring and paperclip solution.

Ghormak

Ah, so THERE'S the documentation for the math plugin! You really should have included all this info in the zip file. ;)

Anyway, sorry for dragging this topic back to life, but I have a question regarding the plugin. Is it just me or does it handle negative numbers badly?

I have in my script something like this:

while(GetWalkableAreaAt(x, y) > 0)Ã,  {
Ã,  here a lot of stuff happens, but the problematic lines are these:
Ã,  wx = fadd(wx, ix);
Ã,  wy = fadd(wy, iy);
}

(I make x and y normal ints from wx and wy for checking the walkable area, naturally.)

Now this works very nicely when ix and iy both are positive numbers, but if one of them is negative AGS crashes on me with this message:

"Script appears to be hung (15001 while loop iterations without an update)"

Is there something I might have overlooked, or is there a problem with the plugin?

Thanks.
Achtung Franz! The comic

Gregjazz

A while ago I announced on this forum that I mirrored all the plugins. I was looking for the math plugin, but it was gone, like you said -- but then I found it on my harddrive and I was happy.

http://herculeaneffort.adventuredevelopers.com/plugins/agscalc161.zip

http://herculeaneffort.adventuredevelopers.com/plugins/agsfile10.zip

http://herculeaneffort.adventuredevelopers.com/plugins/agsscaling10.zip

The Maya plugin is good, too, but here's some very important information to remember: all the sin and cos functions work with radians, not degrees. So I had to make my own function to convert between them, because I love like degrees so much more than radians.

Kweepa

Ghormak, I'll put the info in the zip file this evening.
Good point, I forgot.
(I removed those GetTextExtent calls.)

For your problem, can you post a bit more context? I have been using the plugin extensively with no problems.

GeoffKhan, I'll add some conversion functions - something like
angle_from_degrees()
angle_from_radians()
The second function is a pass through so you don't have to remember whether the trig functions take degrees or radians.
Similarly
degrees_from_angle()
radians_from_angle()

Usage would be, for example
int fx = sin(angle_from_degrees(fy));
or
int fangle = degrees_from_angle(atan2(fy, fx));

Cheers,
Steve
Still waiting for Purity of the Surf II

Ghormak

Whoops, nevermind! The problem was just stupidity on my behalf. It works splendidly.
Achtung Franz! The comic

SMF spam blocked by CleanTalk