Jump to content
Sign in to follow this  
XCess

Math

Recommended Posts

Recently I've be unable to avoid the need for more than basic mathmatics in my scripts, and by basic I mean school taught stuff. So now I'm looking to expand my knowledge in this area, but I don't wish to take on a full blown college or uni course on the subject as I would doubtlessly tire of it while they do arithmatic revision or basic multiplication to get the class back into the correct mindset.

Anyways, the question I'm asking is: are there any online math courses, for free where I can expand my mostly forgotten grasp of maths?

Share this post


Link to post
Share on other sites

I've always wanted to be good at scripting but it looks so damn complicated. sad_o.gif

Share this post


Link to post
Share on other sites

Depends what you're trying to do.

Anything with units, waypoints etc => generally fairly easy (unless you're doing something as epic as THobson's Abandoned Amish). Only a limited number of commands, most easy to learn.

Anything with the drop command => way out of my league.

As soon as the happy trigonometric trio of sin, cos and tan show up, I'm out of there. I did well at maths in school, but I'll be damned if I'm gonna waste my time working on a problem while I'm meant to be playing a game.

Share this post


Link to post
Share on other sites
Recently I've be unable to avoid the need for more than basic mathmatics in my scripts, and by basic I mean school taught stuff. So now I'm looking to expand my knowledge in this area, but I don't wish to take on a full blown college or uni course on the subject as I would doubtlessly tire of it while they do arithmatic revision or basic multiplication to get the class back into the correct mindset.

Anyways, the question I'm asking is: are there any online math courses, for free where I can expand my mostly forgotten grasp of maths?

What school did you go to... crazy_o.gif I find most of the math used in scripts is, by today's standards, high school level. Well, at least the classes I took. But then again I've always been good at math, goold old logical math. I love math, you can use it to do so many things. inlove.gif

Cameron, that's a shame, trig probably gets the most use in scripting, it's very useful.

Share this post


Link to post
Share on other sites

Agreed, but I tend to shy away from things like that. Basically what I script for is limited to cutscenes and objective-based stuff. I leave the heavy gear to the real pros, like you.

Share this post


Link to post
Share on other sites

I was almost certain I put this in OT to begin with huh.gif

Anywaus, I'm talking about stuff like placing objects in a certain degree facing the object which they are placed relative to and also placed in a pattern. Most of the math i learned in school, well, it left my brain ther day I left the school sad_o.gif

Scripting isn't an issue, I've got 80% of the comref memorised from these past five years. It's just, I want to have total control over units, vehicles, weapons and bullets, whether it's with placement, movement or anything else I come across.

The next step up from my most recent script, the Velocity Control one (in mission editing/ scripting). Because that script kind of got me to the peak of my knowledge, and I can see myself setting targets above that tounge2.gif

*edit* oh yes, where exactly did I put this thread to begin with crazy_o.gif

Share this post


Link to post
Share on other sites

I think I know where you are trying to head.

You want to know more about algorithms that are used often in game programming? i.e. scripts?

Start here: http://www.aiwisdom.com/

Take what they teach and learn to draw the mathmatical basics from it. Then search on the topics of the most interest to you.

I have two books of the series. I was just a simple app programmer that did basic things like inventory control and data collection. After reading these books I finally understood why statistics, contemporary applications of math, calculus and trigonometry were important. I have been a math hobbyist, more into just using the concepts rather than learning the details. This book helped me find what to use rather than getting a degree in math just to figure it all out. Ever since, it has never felt like work to me to do a problem when it is related to game programming.

Share this post


Link to post
Share on other sites

Well for unit placements and angles and such would be covered by Geometry/Trigonometry. Now I dunno what education you have but the needed basics for this are taught in High School here. More advanced concepts might not be covered but it depends on your level and special courses. However. To start with you should check back in your old schoolbooks if you still have them. They ususally explain the things very well and also provide enough exercises. Once you have the basics in your head you can solve virtually any placements issue with some imagination and knowledge of the "trigonometric toolbox" you have at your disposal. Some solutions might be quite complicated though if you don't know advanced concepts. Personally I don't know any online "tutorial" on this but there's a good chance something like that would exist. Another source might be Wikipedia but IMHO I find their "explenations" are not very well suited to learn stuff. It's good to remember stuff you once knew though. Another good source is always a good library, especially university libraries. They should have many books aimed at education in all kind of topics.

For Velocity stuff you want to check the topic of Vectors in Physics and Math.

Share this post


Link to post
Share on other sites

That's it. Also check out things like velocity, acceleration, speed (note velocity and speed are not the same thing). But if you want the nutcase stuff, you might have to venture back into sincostanville.

Share this post


Link to post
Share on other sites
But if you want the nutcase stuff, you might have to venture back into sincostanville.

Well it's kinda funny that people seem to be so "afraid" of it because the trigonometric funtions are very easy actually. I know it's a pain to learn them and keep them in your head but once you got the basics memorised it's really nothing special. And it's incredibly powerful. I'd say the effort is well worth it considering what you can do with it then wink_o.gif

Share this post


Link to post
Share on other sites

Trying to hack high school advanced mathematics was pretty much impossible for me with a good teacher and many hours, some online course would seem even more far-fetched for me at least. crazy_o.gif

Share this post


Link to post
Share on other sites

Hi all

To XCess well done!

You have redefined your problem in your second post. smile_o.gif You have almost solved it all your self

In your first post you problem was !MATH! which is a very big problem and no mean feat for anyone. Over history there have been few people who really understood !MATH!.

You have only two areas of specific interest just a little bit of math.

Trigonometry sometimes called "Trig" (High school grade)

http://en.wikipedia.org/wiki/Trigonometry

You know most of this already but probably forgot it as you have not had to apply it.

You can then break that up even further into

sine, cosine and tangent there are links on each on that page I posted above.

And low level Newtonian Physics simple laws of motion stuff (High school grade)

You probably know most of this already but forgot it as you have not had to apply it.

To apply both of these you need

http://community.bistudio.com/wiki/Main_Page

The first thing you need to do is getting something to move around in a circle and spin around. Once you can do that you have mastered most of your Trig needs.

The Commands you are looking for are the trig commands:

sin, cos and tan also asin acos and atan.

You will also need the commands

"direction" to find out an objects current direction

"setDir" to change the direction to the one you set

"setPos" to move an object around

Then you need to get things to move in parabolas

The commands you need are:

setVelocity and the commands above.

The setVelocity command in the BIS wiki has a nice example.

Suggested course of learning

I suggest you do all this some where flat like the airport. (this is to reduce variables and give you a nice flat place to see the effects of what you are doing)

First of all get an object to spin

You just need the setDir to make it face direction

Then you need to make a loop that does two things

One to increase the spin number by an increment and Two to zero the number when it reaches one increment below 360.

Next get an object to move in a circle. (NOTE this not the same as above)

For this you need setPos and your trig commands.

Once you have an object moving in a circle combine it with the spin loop and the Direction command (to find out what direction it is in) to make the object always face outward.

Once you have this working give us a shout on this thread and somone can take you through throwing things in parbolas. Although to tell the truth I think you will be able to figure it out for yourself by then wink_o.gif

You may want to look up my working lighthouse on OFPEC as an example of the above but try and figure it out your self as then you will remember it better. wink_o.gif

Kind Regards Walker

Share this post


Link to post
Share on other sites

Thanks Walker, and yes, I think my problem is that I forgot almost everything I learned in school. Never thought I would need it and so it vanished from my head icon_rolleyes.gif

Gonna take a look at the links you gave. I'll report back soonish.

Share this post


Link to post
Share on other sites

If you need help, I might be able to help... doing 2nd year in the Finnish High School system, and got both "long" maths and physics... and chemistry. wink_o.gif

Share this post


Link to post
Share on other sites
But if you want the nutcase stuff, you might have to venture back into sincostanville.

Well it's kinda funny that people seem to be so "afraid" of it because the trigonometric funtions are very easy actually. I know it's a pain to learn them and keep them in your head but once you got the basics memorised it's really nothing special. And it's incredibly powerful. I'd say the effort is well worth it considering what you can do with it then wink_o.gif

I agree, it's as easy as knowing how to multiply or divide really, and remembering SOH CAH TOA (what I learned), which means sine=opposite/hypotenuse, cosine=adjacent/hypotenuse, and tangent=opposite/adjacent. Then you just need to figure out how to apply trig in OFP, which is basically a big 3 dimensional coordinate system. Vectors are also useful to know, so you can work with velocity. And the nice thing about OFP is you don't have to worry about negative or reference angles, and you work in degrees instead of radians (except for configs, oddly).  smile_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]One to increase the spin number by an increment and Two to zero the number when it reaches one increment below 360.

A tiny note, since this is an often done and mostly annoying step:

It's much cleaner to use the modulo function for that, as in

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">newDir = (oldDir + 1) % 360

Share this post


Link to post
Share on other sites
Quote[/b] ]One to increase the spin number by an increment and Two to zero the number when it reaches one increment below 360.

A tiny note, since this is an often done and mostly annoying step:

It's much cleaner to use the modulo function for that, as in

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">newDir = (oldDir + 1) % 360

Hi hardrock

Yes we could get into a whole world of more complex and efficient methods of achieving a piece of code.

And I would aplaud them but...

We are looking for readable code for a novice not for a peice of hirerglyphics they will not understand. wink_o.gif

One must walk before one runs.

Consider modulo operations may be slower than the bitwise alternative and you are after all calculating a division every cycle there. A multiplication of a boolian result may be quicker.

http://webster.cs.ucr.edu/AoA/Windows/HTML/IntegerArithmetic3.html

http://www.quadibloc.com/comp/cp0202.htm

http://escience.anu.edu.au/lecture....en.html

For personal code I often do something like this; as with yours it is in a loop of course.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">newDir = (newDir + 1) *newDir < 360

Edit :Not sure if that 360 should be 359 or even 361 I usualy just run it through to test. Thinking about it 360 = 0 on a compass so 359 is what it should be!

There is a boolian comparison plus a multiplication plus an addition so I guess one more operation; however the nature of a division calculation is many operations in the processor and you are actualy taking the modulus which is probably an inherent third operation anyway. So I think the method I show is probably faster. Also note I am using one less variable. As this is interpreted script in OFP the difference is probably negligable. And as my trick is in OFP script and boolian resolves to a True False rather than the mathmatical 1 and 0 it may not work. It does work in C++ which is where such tricks are often useful.

Edit: Thinking about it some more, an array of 360 elements with the numbers "1" to "359" and ending with a "0", and combined with the following pseudo code is even more efficient

Something like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_heading = 0

Loop begins

display heading

_heading = arrayOfHeading select (_heading)

Loop End

But on a readability scale I would not use either in this case. I would only use such methods if the process was very intensive.

And as I said this is a novice learning to program.

Kind Regards Walker

Share this post


Link to post
Share on other sites

u should also study the basics of matrix operations. absolute/relative movements(analitic geometry) are calculated with transformation matrix. even for shaders u use them...so i guess its a good idea for u to learn some general basics.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×