YesNoOk
avatar

Ln (math) (Triggers) (Read 3406 times)

Started by JustNoPoint, October 14, 2015, 07:55:37 pm
Share this topic:
Ln (math) (Triggers)
#1  October 14, 2015, 07:55:37 pm
  • ******
    • www.justnopoint.com/
Returns the natural logarithm of its argument. This produces slightly more accurate results than the otherwise equivalent expression log(e,(argument)).

Format:
ln(exprn)
Arguments:
exprn
Expression to compute the natural logarithm of (float).
Return type:
float
Error conditions:
Returns bottom if exprn evaluates to bottom, or if exprn is not positive.
Example:

Code:
value = ln(time)
  Sets value to the natural logarithm of the player's statetime.
Re: Ln (math) (Triggers)
#2  October 14, 2015, 08:18:37 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
Tagging @Daniel9999999: since he has a lot more experience utilizing this trigger than I do and could probably clearly explain some practical uses for it better than I can, most notably using it to set boolean flags and such.
Last Edit: October 14, 2015, 08:23:01 pm by Ricepigeon
Re: Ln (math) (Triggers)
#3  October 14, 2015, 09:26:40 pm
  • ****
  • it's me
  • Bat's a Wrap.
    • Chile
    • koakoa@jabber.org
    • Skype - koakumadevil69
Hello, it's interesting to note that Exponentiation (exp(x)) and the natural logarithm are inverse functions of each other in the interval (0,+inf), One use that Ricepigeon is referring to is the expression exp(2*ln(x))) which closely equals to 2^x  (not exactly equal, remember, MUGEN's floating point accuracy is baaaaaad). that we abused so we could just copypaste code and change one number and work faster, and also since we use it together with boolean flags, which work with powers of two, however, if you want to ACTUALLY use the integer number, you have to round it off some way, either floor(exp(2*ln(x)) + 0.5) or ceil(exp(2*ln(x)) - 0.5) will do the job for returning 2^x just fine and then you can just copypaste abuse :p. Note that x can be even an float, so you can use it to calculate square roots, inverses and stuff, more info about it here: http://mugenguild.com/forum/msg.64497

I am not sure of how fixed the "**" thing is in 1.0, but it's a nice tool to have if you don't trust MUGEN's basic operations... For WinMUGEN (compatible or exclusive) users, this (or Bia's method) is the way to go.
Yeaaaah im shootign ducks wiht the paino