YesNoOk
avatar

Math for the Algebraically Challenged (Read 10408 times)

Started by Bronko, November 20, 2005, 04:19:10 pm
Share this topic:
Math for the Algebraically Challenged
#1  November 20, 2005, 04:19:10 pm
  • ******
  • Just a butcher on a mission.
    • www.justnopoint.com/lbends
Okay I'm starting this thread as a "demonstration" of math operations to help total newbs manipulate variables in mugen.  In this case, time is the only variable.  I will post some of the basics and everyone else can add on to it. (I have supplied pictures for this tutorial, if you do not provide one I can make it for you.)

To start, here we have a set of Axes.  The origin is at the left-center, 0,0.

For all extents and purposes, we will assume the X axis represents Time.  Throughout this demonstration we will be manipulating time, which is why the graph does not include negative numbers in the X direction.
First we have constants. Constants are just unchanging numbers, like 10 and 20.  Here we have Y= 0, Y=10, and Y = 20

Notice they do not change due to time.  This is because time is not included in the expression.  However if we plotted Y = Time

You can see that Time is equal to itself, for obvious reasons.  We can shift this plot in many ways such as the four basic operations, addition,subtraction,multiplication, and division.

Using addition, you can set where the graph starts from, useful for possibly an attack that increases in damage the longer you charge it (Charging it for 0 time will still produce some damage)
Using multiplication or division, you can make that same attack charge faster or slower without having to change the laws of physics and cause time to go faster or slower.
Now we get more complicated.  Suppose the attack mentioned earlier was charging too slowly for you, but time*1000 is way too broken.  You can use an exponent for this.

Time^2 is just another notation for Time*Time. The bigger the exponent, the faster the graph curves upward.  And just as the inverse of multiplication is division, the inverse of an exponent is a logarithm.

I think you get the idea.
However by far the most useful operation is the modulus.  Modulus is like division, but instead returns the remainder of the operation, not the quotient.

I have also graphed y=10 to show that the graph never goes to ten, because the remainder of any multiple of ten divided by ten is always zero.  This is great for times when you want to do something every X ticks.  Lastly, we have trigonometric functions.  For now I will only demonstrate the sine curve.

This is a bit complicated, so I'll go into detail about the expression first.
20*sin((pi/12)*time)
Normally a sin function goes from 1 to -1, so I multiplied it by 20 to make the range 20 to -20.  Then on the inside, I multiplied time by PI and then divided by twelve.  The period (or how long it takes for the sine curve to repeat) is usually 2*PI, which is around 6.28, not a very clean number if you ask me.  The period of my equation is 24, so it repeats whenever time is a multiple of 24.  Why?  Because 2*PI/(PI/12) = 24 :) If I multiplied time by PI/6 instead, my period would be 2*PI/(PI/6) = 12  You can use the sin curve for all kinds of things, but it's main usage comes from palette effects, such getting hit by fire.  The player should gradually go from normal to red and back again.

If any of this is too confusing/could be explained better let me know.
One last note: In mugen, it doesn't hurt to add .0 to every number to make sure mugen doesn't truncate anything (cut off the decimals).
Last Edit: November 25, 2009, 03:38:20 pm by Insanius
Re: Math for the Algebraically Challenged
#2  November 21, 2005, 01:10:45 am
  • *****
    • Peru
...and it doesn't hurt to truncate an expression with ceil() or floor() to avoid that nice debug warning messages...

Nice tutorial. Basic stuff that any creator should know (and should learnt at school).
Re: Math for the Algebraically Challenged
#3  November 21, 2005, 08:11:12 am
  • ****
  • 君の事、マスターにしてあげる! 御願い、信じてマスター!♥
    • Philippines
    • Skype - o_hermanm
    • www.rotbrc.com
To save on SFF space and added flexibility, any explod that revolves or moves around the character should be programmed with algebraic expressions instead of absolute positioning from sprites.
Orochi Herman: MUGEN Creator, Producer and Web Programmer
https://www.facebook.com/OrochiHerman/
Re: Math for the Algebraically Challenged
#4  November 21, 2005, 02:19:37 pm
  • ***
  • I love this pic XD
    • www.furnation.com/foxphoenix
Quote
(and should learnt at school).

This was too advanced for a puertorican school at my age so I could never learn most of this stuff.
Re: Math for the Algebraically Challenged
#5  November 22, 2005, 01:22:52 am
  • avatar
  • ***
FEh.. too easy...  :D

sup Mugen coding class 101  :P
Goodbye V ^_^ V
Re: Math for the Algebraically Challenged
#6  November 22, 2005, 11:57:58 am
  • ***
  • I love this pic XD
    • www.furnation.com/foxphoenix
FEh.. too easy...  :D

sup Mugen coding class 101  :P

Well. It's stated in the topic title. "Math for the Algebraically Challenged" Not everyone could learn this stuff or is good enough for it. And I apply for both things  :P

@Jazzy. If you have more stuff to add here. I'm all ears ...errr eyes!  --;
Last Edit: November 22, 2005, 11:59:38 am by Foxphoenix
Re: Math for the Algebraically Challenged
#7  November 22, 2005, 06:56:42 pm
  • **
  • What?
It was good if somebody translate the tutorial to spanish... :sugoi:
Re: Math for the Algebraically Challenged
#8  November 25, 2005, 10:19:44 pm
  • ****
  • Now your gonna feel my hooks! OH YEAH!!
Meh. You lost me at "20*sin((pi/12)*time)" Was never a math wiz. If I could learn this it would be a friggin miricle. -_-
Re: Math for the Algebraically Challenged
#9  November 25, 2005, 11:00:34 pm
  • ***
  • Vans Worshipper
  • Ø
    • www.fongo-world.com
it means "20 multiplified by sin[that cool and useless thing that you learn in the 8th grade]((pi divided by 12)* teh time)" what's so hard???
Last Edit: November 25, 2005, 11:05:39 pm by Knuckle Sandwiches
Re: Math for the Algebraically Challenged
#10  November 29, 2005, 03:21:59 pm
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/
What's so hard is that not everybody is good at maths or had the chance to be able to learn this at school.

And, understanding the formula as you did isn't the most complicated part. The complicated part is to understand what it's meant for, and what effect or purpose it will finally give.
Re: Math for the Algebraically Challenged
#11  December 14, 2005, 08:52:28 am
  • avatar
  • ***
ARe these for how the way the character moves in mugen?

I would like to know..  :-\
Goodbye V ^_^ V
Re: Math for the Algebraically Challenged
#12  December 14, 2005, 12:46:59 pm
  • ******
That's for anything mathematical. If you want to give a mathematical move to your char (a sinusoidal projectile for example), you have that.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.
Re: Math for the Algebraically Challenged
#13  September 22, 2007, 06:50:00 am
  • avatar
  • **
Re: Math for the Algebraically Challenged
#14  September 22, 2007, 06:56:11 am
  • *****
    • Peru
Take Strider Hiryu's Uroboros as an example.
In that move, two projectiles move around Hiryu. Instead of adding a lot of sprites with the projectiles positioned in different angles, you can just use some math and one sprite.

The first Hiryu I downloaded was programmed not using math, and the Uroboros looked and played like crap :(
Re: Math for the Algebraically Challenged
#15  September 22, 2007, 04:30:34 pm
  • *****
  • corner push pusher
#Shaun never took trig.  ;P
#Shaun never took calculus :P
#Shaun barely passed Algebra. :ninja:

After finding this topic, #Shaun will now have a better understanding of what type = projectile, trigger = time % 60, offset = 10 + ( floor(time/60) * 20 ), 0 means. Thanks!
Re: Math for the Algebraically Challenged
#16  October 17, 2007, 11:42:23 pm
  • **
  • Conic Team nod your head
    • www.freewebs.com/conicteam/
I did not learn this stuff yet :o
Re: Math for the Algebraically Challenged
#17  October 29, 2007, 05:50:47 pm
  • ****

No Borders, No Nations
Re: Math for the Algebraically Challenged
#18  November 09, 2007, 08:54:00 am
  • ***
  • It's not furry you goons, it's anthro! ANTHRO!
I'm still having trouble understanding this. I'm a visual learner, so could you maybe give some examples of these in actual Mugen code? I'm interested in learning this so I can make my characters main projectiles (floating fire) move at angles and sines without having to rely on sprite positioning.
A magical force-field surrounding a brick in an iron vault...even if the security is breached, the thieves are bound to be disappointed.

DMK

Re: Math for the Algebraically Challenged
#19  November 09, 2007, 10:01:35 am
  • ******
  • 141⅔% chance of winning
    • USA
    • www.twitch.tv/ThisbeDMK
Lol, I remember reading this and wondering what in the flying fuck you were going on about.

Now that I know what the axis and all that stands for it's like looking at a small tutorial.  :D
Re: Math for the Algebraically Challenged
#20  November 09, 2007, 03:44:36 pm
  • ******
  • Just a butcher on a mission.
    • www.justnopoint.com/lbends
Given the amount of interest, I will be expanding this further in the near future.

I'm a visual learner, so could you maybe give some examples of these in actual Mugen code?
Ask and ye shall receive.