They can do many different things. For example, set size to abs y position. This means that it will set the size to distance from y=0, even if it is negative. The other blocks can be used for realistic movement, and many other things as well.
Offline
Abs is different from the other functions you mentioned because it isn't a trig function.
The abs function turns a negative number into a positive number and positive numbers will remain positive.
For info on the trig functions go to http://scratch.mit.edu/forums/viewtopic.php?id=5326
Offline
lilhd wrote:
I know what they mean in math. Sine, Cosine, Tangent, and Absolute Value but what do they do in games?
Assume that you have a game in which projectiles are being fired at a castle wall and you need to compute the force of the impact of the projectile on the wall. If the projectile strikes the wall at an angle of 90 degrees (perpendicular), the force of the impact will be maximum. If the projectile barely grazes the wall (at an angle near zero degrees), the force of the impact will be near zero.
Those two cases are easy and obvious. However, what is the force of impact for angles between 90 degrees and 0 degrees? To a first degree of approximation, the force of the impact will be the product of the maximum force and the sine of the angle of impact.
For example:
sin(0) = 0
sin(45) = 0.707
sin(90) = 1
The force of impact = max * sin(angle of impact)
Force of impact at 90 degrees = max
Force of impact at 45 degrees = max*0.707
Force of impact at 0 degrees = max*0 = 0
Note that for an angle of 45 degrees which is half way between 0 and 90, the force of impact is a little more than half the max.
I am currently publishing a series of tutorials on Math for Game Programmers.
The first lesson is at http://www.developer.com/java/other/article.php/3733176
The second lesson is at http://www.developer.com/java/other/article.php/3739171
The third lesson is at http://www.developer.com/java/other/article.php/3744921
Other lessons will be forthcoming and you will find links to them in my Java tutorials (see below).
Offline
ok. and what does asin, acos, atan, ln, and log mean. I'm sure i now it. I just dont get the abbreviations. Ill be a sophmore in high school next year. (This came out of nowhere but do you think a good new block would be for it to pause something and then play it like a menu system or something)
Last edited by lilhd (2008-05-23 19:28:11)
Offline
asin = arcsine (inverse of the sine function)
acos = arccosine (inverse of the cosine function)
atan = arctangent (inverse of the tangent function)
ln = natural logarithm (Euler's constant as a base)
log = base 10 logarithm
As for the 'menu block' idea...that could be pretty cool but hard to set up. Lots of options and inputs go into making a menu.
Offline
Paddle2See wrote:
asin = arcsine (inverse of the sine function)
acos = arccosine (inverse of the cosine function)
atan = arctangent (inverse of the tangent function)
ln = natural logarithm (Euler's constant as a base)
log = base 10 logarithm
As for the 'menu block' idea...that could be pretty cool but hard to set up. Lots of options and inputs go into making a menu.
I will take the liberty of elaborating on the explanation given by Paddle2See:
sin - given an angle, find the value of the sin of the angle
asin = arcsine (inverse of the sine function) - given the sin of an angle, find the angle whose sin is that value
Example:
sin(45 degrees) = 0.707
asin(0.707) = 45 degrees
cos - given an angle, find the value of the cos of the angle
acos = arccosine (inverse of the cosine function) - given the cos of an angle, find the angle whose cos is that value
tan - given an angle, find the value of the tan of the angle
atan = arctangent (inverse of the tangent function) - given the tan of an angle, find the angle whose tan is that value
ln = natural logarithm (Euler's constant as a base) - you probably won't need to know about the natural logarithm until you get into some pretty advanced material.
log = base 10 logarithm
For the base 10 and a value such as 100, the log function returns the power or exponent to which the base 10 must be raised in order to produce the given value. For example, if the value is 100, the log of 100 is 2 because 10 must be raised to the second power to produce 100.
Possibly the most important set of logarithms that you will encounter in game programming involve the base 2. This can be important if you get involved in shifting bits.
Offline
Click my name, and then Mirror Draw. Download it to see a good example of ABS
Offline
I don't want to spam but I have a project that teaches about sine and it is very simple-it's called Sine Wave Tutorial
Offline