[FREQ] Math Functions

If you have an idea for a new feature, please discuss it in the main MapTool forum first, then post a summary of the discussion here. Use the first Sticky as a template.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

[FREQ] Math Functions

Post by RPTroll »

Expose sin, cos, atan, atan2, mod and other java math functions as macro calls. We have some of those now. I specifically would like to see the trig functions added to make angle computations easier. Thoughts?
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: [FREQ] Math Functions

Post by JamzTheMan »

Should be faster to.

Should they be a bunch of new functions or 1 'math' fun like math('sin', x).
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

d4rkAlf
Cave Troll
Posts: 35
Joined: Thu Apr 16, 2015 9:48 am

Re: [FREQ] Math Functions

Post by d4rkAlf »

I could definitely do this. The biggest problem as I see it is that in order to write "clean" software I think I need access to the parser part of the source code. Or at the very least someone has to tell me other places except from the childEvaluate method where the parser can enter the client code.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: [FREQ] Math Functions

Post by wolph42 »

JamzTheMan wrote:Should be faster to.

Should they be a bunch of new functions or 1 'math' fun like math('sin', x).
i'd prefer separate functions. and while we're on it: a parameter to choose between radians and degrees (defaulting to degrees).
So

Code: Select all

sin(30[, useRadians])
Functions:
sin, cos, tan, cotan, pi, degrees2radians, radians2degrees.

other useful math functions are:
mod, abs, odd (or isOdd), div.

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: [FREQ] Math Functions

Post by Jagged »

d4rkAlf wrote: The biggest problem as I see it is that in order to write "clean" software I think I need access to the parser part of the source code.
I believe getting those sub-projects into Git is on Graig's ToDo list ;)

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Re: [FREQ] Math Functions

Post by RPTroll »

Those project are currently housed on the old SVN site if you want the source.
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

d4rkAlf
Cave Troll
Posts: 35
Joined: Thu Apr 16, 2015 9:48 am

Re: [FREQ] Math Functions

Post by d4rkAlf »

RPTroll wrote:Those project are currently housed on the old SVN site if you want the source.
Is it this link: http://sourceforge.net/p/rptools/svn/HEAD/tree/ ?

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Re: [FREQ] Math Functions

Post by RPTroll »

Here's a forum lnk about getting the code. Other coders please make sure this is the right spot.

http://forums.rptools.net/viewtopic.php?f=7&t=421
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: [FREQ] Math Functions

Post by JamzTheMan »

d4rkAlf wrote:I could definitely do this. The biggest problem as I see it is that in order to write "clean" software I think I need access to the parser part of the source code. Or at the very least someone has to tell me other places except from the childEvaluate method where the parser can enter the client code.
Why exactly do you need the parser?

These should just be "Macro Functions". It would just be a new class to house a few new functions and there is a standard "hook" to add these.

You just need to add the new class to mapToolParserFunctions in MapToolLineParser.java.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

d4rkAlf
Cave Troll
Posts: 35
Joined: Thu Apr 16, 2015 9:48 am

Re: [FREQ] Math Functions

Post by d4rkAlf »

RPTroll wrote:Here's a forum lnk about getting the code. Other coders please make sure this is the right spot.

http://forums.rptools.net/viewtopic.php?f=7&t=421
Thank you, that does look right. :)
JamzTheMan wrote:
d4rkAlf wrote:I could definitely do this. The biggest problem as I see it is that in order to write "clean" software I think I need access to the parser part of the source code. Or at the very least someone has to tell me other places except from the childEvaluate method where the parser can enter the client code.
Why exactly do you need the parser?

These should just be "Macro Functions". It would just be a new class to house a few new functions and there is a standard "hook" to add these.

You just need to add the new class to mapToolParserFunctions in MapToolLineParser.java.
Thank you! That was exactly what I needed to know. :D

I only thought I needed more source code since the method childEvalute (in TokenPropertyFunctions) is never referenced from any of the code that is currently on Github. (If I knew where it was referenced from I could work my way from there.) That was the only method I knew of which was able to handle macro functions.

For example now that I know where to look I found the class net.rptools.parser.function.AbstractFunction. Since it is the SuperClass of all the relevant classes it would have helped me greatly if I was able to look for references to it.

Seeing as I'm still rather new to the Maptool codebase it would be nice to have someone more experienced to talk to. I'm not thinking of anything too fancy, just someone that I can send questions to when I don't know where to look for something. It would be much preferable when compared to making dumb forum posts. :lol: Would it be alright with you to act as a sort of "mentor" to me?

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: [FREQ] Math Functions

Post by JamzTheMan »

Not a problem at all. Just wanted to make sure, never know if someone has deeper reasoning behind a request or simply looking for how to do something.

Feel free to PM me and I can give you my email. BUT, I also don't mind forum post questions either, there are no "dumb" questions. Who knows, we may have just answered the same question for 4 other people (past or present) looking for the same.

Maybe we just need a generic forum topic for Java related "Where do I find..." or "what's the best way to do..." sort of questions, keep them wrangled together.

I can usually quickly answer questions where it relates to code I've been in (Functions, lighting, assets, UI) but there's plenty of parts of the code I haven't dived deeply into (server/client calls, parsers, network code, etc) that others may be able to answer.

It's a little intimidating at first but once you poke around and start tracing classes back to the root you'll find your self in the same few dozen classes quite often and things start looking familiar. :D

Given that, you'll probably be able to whip these functions out really quickly. Wolf will probably be a great asset in helping test them out and getting the Wiki updated for new functions.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: [FREQ] Math Functions

Post by Jagged »

JamzTheMan wrote:It's a little intimidating at first
$deity yes!

User avatar
RPTroll
TheBard
Posts: 3159
Joined: Tue Mar 21, 2006 7:26 pm
Location: Austin, Tx
Contact:

Re: [FREQ] Math Functions

Post by RPTroll »

JamzTheMan wrote:Should be faster to.

Should they be a bunch of new functions or 1 'math' fun like math('sin', x).
Would this save a lot of coding to just do a pass through to the java math package?
ImageImage ImageImageImageImage
Support RPTools by shopping
Image
Image

d4rkAlf
Cave Troll
Posts: 35
Joined: Thu Apr 16, 2015 9:48 am

Re: [FREQ] Math Functions

Post by d4rkAlf »

RPTroll wrote:
JamzTheMan wrote:Should be faster to.

Should they be a bunch of new functions or 1 'math' fun like math('sin', x).
Would this save a lot of coding to just do a pass through to the java math package?
Yeah, my current idea is to simply implement macro functions that call the corresponding method in the standard Java library. I just needed to know where to put them.

d4rkAlf
Cave Troll
Posts: 35
Joined: Thu Apr 16, 2015 9:48 am

Re: [FREQ] Math Functions

Post by d4rkAlf »

JamzTheMan wrote:Not a problem at all. Just wanted to make sure, never know if someone has deeper reasoning behind a request or simply looking for how to do something.

Feel free to PM me and I can give you my email. BUT, I also don't mind forum post questions either, there are no "dumb" questions. Who knows, we may have just answered the same question for 4 other people (past or present) looking for the same.

Maybe we just need a generic forum topic for Java related "Where do I find..." or "what's the best way to do..." sort of questions, keep them wrangled together.

I can usually quickly answer questions where it relates to code I've been in (Functions, lighting, assets, UI) but there's plenty of parts of the code I haven't dived deeply into (server/client calls, parsers, network code, etc) that others may be able to answer.

It's a little intimidating at first but once you poke around and start tracing classes back to the root you'll find your self in the same few dozen classes quite often and things start looking familiar. :D

Given that, you'll probably be able to whip these functions out really quickly. Wolf will probably be a great asset in helping test them out and getting the Wiki updated for new functions.
Thanks a lot!

I agree about gathering all those questions in one place. My problem at the moment is that I don't have access to the Java Programming Info subforum.

Do you know where the currently available math functions are located? I'm thinking of the ones listed under Category:Mathematical Function on the wiki? It seems logical that the new ones should be implemented in the same place.

Post Reply

Return to “Feature Requests”