# Imaginary Numbers

120 replies to this topic

### #1 kibblesbob

kibblesbob

"Xarrot Studios"

• GMC Member
• 215 posts
• Version:GM:Studio

Posted 10 March 2011 - 06:16 PM

Well I was working on a quadratic equation calculator, and everything works fine except when you have a negative discriminant. Now we all know that when you try to take the square root of a negative number ( EX - sqrt(-24) ) , game maker will give you an error saying "Cannot apply sqrt to negative number". But why? my graphing calculators can, and so can most of the other quadratic calculators on any given site. So why doesn't GM have a value for 'i'? I don't need an explanation of the mathematics, I already covered that. I want to know why GM doesn't have this feature for imaginary numbers.
• 0

### #2 FakeKraid

FakeKraid

Total Fraud

• GMC Member
• 66 posts
• Version:GM8

Posted 10 March 2011 - 06:21 PM

Well, aside from a program devoted to solving equations, what purpose would it serve? You can only plot real numbers on a 2D graph, and in the end, that's essentially all Game Maker is supposed to do. I can't think of any conceivable purpose 'i' would have in an ordinary game. Perhaps I'm just narrow-minded?
• 1

### #3 kibblesbob

kibblesbob

"Xarrot Studios"

• GMC Member
• 215 posts
• Version:GM:Studio

Posted 10 March 2011 - 06:28 PM

the only imaginary number I would plan on using more than once is 'i' which is equal to sqrt(-1), and from that i^2 is equal to -1. the only reason i would need them though is to make my life MUCH easier when doing things with parabolas and other quadratic functions. Its not a big deal though, it just means i have to work around it
• 0

### #4 Erik Leppen

Erik Leppen

GMC Member

• GMC Member
• 2751 posts
• Version:GM:Studio

Posted 10 March 2011 - 06:31 PM

What were you planning to use it for?

Also I don't know of any programming languate that natively supports complex numbers. Real, string, float, double, boole are default data types, I have never seen "complex" as a data type. This is to be expected, since a complex number is essentially a vector with two coordinates (the real and the imaginary part), following a few special rules of arithmetic (the multiplication rule in particular). So to emulate complex numbers all you have to do is work with vectors of size two, and define the multiplication rule and the and nth power root rule for those.

In GM this can be done with lists. I don't see exactly what's wrong with writing your own algorithms for complex numbers that work on lists of size two.

Edited by Erik Leppen, 10 March 2011 - 06:32 PM.

• 0

### #5 Artaex Media

Artaex Media

Artaex Media

• GMC Member
• 1531 posts
• Version:Unknown

Posted 10 March 2011 - 06:45 PM

I don't see why you want to calculate a negative square root.
I mean, sqrt(9) results in 3. (Because 3 x 3 = 9)
But, sqrt(-9) also results in 3, that's because -3 x -3 = 9.

Anaway, complex numbers indeed work a different way...
Maybe check out Wikipedia for that, maybe there's an alternative way of calculating it
EDIT: Typo...

-RefluxLtd

Edited by Reflux Entertainment, 10 March 2011 - 06:48 PM.

• -1

### #6 kalzme

kalzme

GMC Member

• GMC Member
• 329 posts
• Version:GM:Studio

Posted 10 March 2011 - 06:55 PM

• 0

Please check out this poll on the GMC about why so many Game Maker projects tend to fail.

### #7 paul23

paul23

GMC Member

• Global Moderators
• 4147 posts
• Version:GM:Studio

Posted 10 March 2011 - 09:37 PM

What were you planning to use it for?

Also I don't know of any programming languate that natively supports complex numbers. Real, string, float, double, boole are default data types, I have never seen "complex" as a data type. This is to be expected, since a complex number is essentially a vector with two coordinates (the real and the imaginary part), following a few special rules of arithmetic (the multiplication rule in particular). So to emulate complex numbers all you have to do is work with vectors of size two, and define the multiplication rule and the and nth power root rule for those.

In GM this can be done with lists. I don't see exactly what's wrong with writing your own algorithms for complex numbers that work on lists of size two.

Matlab does, as does G/labview. However an imaginary number can actually be considered a simple vector with 2 components. Hence it is already in the suggestion/update list. (Adding the ability to create structures would enable this). Now only if we could overload functions (and operators) complex numbers would be as easy to use as real numbers. - The suggestion to use lists is pretty bad, it works but is very annoying to use (heck one can't even add lists and expect a simple vector addition). And because it is difficult to use it's error prone.
However for the calculations complex numbers DO help, and they should be considered a datatype just like "integers" and "floats" and "strings" are different datatypes.

@RE: you're wrong $\sqrt{-9}$ isn't defined in the natural space, because -3 rimes -3 results to 9.
$\sqrt{-9} = \sqrt{-1} * \sqrt{9}$ and by definition $\sqrt{-1} = i$
• 1

Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

### #8 Rusky

Rusky

GMC Member

• GMC Member
• 2492 posts
• Version:Unknown

Posted 11 March 2011 - 01:38 AM

Besides Python, Fortran and Common Lisp have native complex types and C, C++, C#, Perl, Ruby, OCaml and Haskell all have complex types in their standard libraries. Complex numbers can be used for a few things that might be useful in games or other programs you might want to write with GM- polar coordinates, fractals, etc. They wouldn't always be the best choice and it's understandable why they're not supported, but it would be nice to support at least the extensions to the language needed to add them.
• 0

### #9 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4355 posts
• Version:GM:Studio

Posted 11 March 2011 - 03:08 AM

Well, aside from a program devoted to solving equations, what purpose would it serve? You can only plot real numbers on a 2D graph, and in the end, that's essentially all Game Maker is supposed to do. I can't think of any conceivable purpose 'i' would have in an ordinary game. Perhaps I'm just narrow-minded?

Compare the following:

$\begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix} \begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} a \cos \theta - b \sin \theta \\ a \sin \theta + b \cos \theta \end{pmatrix} \\ \exp(i\theta) (a + b i) = (\cos \theta + i \sin \theta)(a + b i) = a \cos \theta - b \sin \theta + (a \sin \theta + b \cos \theta) i$

In other words, planar rotations can be thought of as multiplication of complex numbers. In particular, if a complex number has a magnitude of one, then it corresponds strictly to a rotation in the complex plane.
• 1

### #10 NakedPaulToast

NakedPaulToast

GM Studio/Mac/Win

• GMC Member
• 8808 posts
• Version:GM:Studio

Posted 11 March 2011 - 09:06 PM

GM likely doesn't handle imainary numbers with the sqrt() function because all it really does is wrap Delphi's sqrt function.

In order to impliment it, Mark would have had to recreate that function. Given that imaginary numbers is not in large demand for a game creation tool, then it wasn't worth it.

The same can't be said for your calculator, where the ability to use imaginary numbers is in demand.
• 1

If the Bible truly is inspired by God, you would think that somebody as omnipotent and all-knowing would have known to get his message out using TCP instead of UDP.

### #11 MasterOfKings

MasterOfKings

The True Master

• GMC Member
• 4888 posts
• Version:GM8

Posted 20 March 2011 - 02:15 AM

GM understands strings and reals. Imaginary numbers don't properly exist; as any two numbers of the same type (positive or negative) will never be negative. 'i' was introduced as to allow mathematicians overcome this.

But, ask yourself; in GM, a program designed and built to make simple 2D games, why would it need to understand the square root of -1? How many games would need it?

-MoK
• 0

Did I help you? If so, help me by pressing the + button above here.

### #12 GameGeisha

GameGeisha

GameGeisha

• GMC Member
• 6565 posts
• Version:GM:Studio

Posted 20 March 2011 - 03:10 AM

But, ask yourself; in GM, a program designed and built to make simple 2D games, why would it need to understand the square root of -1? How many games would need it?

If put into common practice, 2D games can benefit from complex numbers.

Complex numbers have applications in 2D geometry. Both the distance between two points and the angle from one point to another have elegant representations if the points are given as complex numbers. And as xshortguy has demonstrated, rotations work well with complex numbers.

You can also treat this as coupling x and y into one variable, allowing for easy storage in variables and use in various functions. Instead of putting in the coordinates as two arguments in a function, we can have the x coordinate as the real component and the y coordinate as the imaginary part, taking up one argument space. Now, search through the manual for functions that take coordinate values as arguments --- you can see that some of the arguments take up a lot of room.

If complex numbers are to be implemented into GM, I expect quaternions to be too --- they function in similar ways compared to complex numbers (except with two more components, j and k, whereas i^2 = j^2 = k^2 = ijk = -1). They greatly simplify coordinates used in 3D, especially with regard to rotations. And let's not forget how many argument spaces it would save for d3d_*() functions.

GameGeisha
• 0
Latest Releases:
• GMLinear --- Matrix and vector math in one line!
• GMAssert --- Debug invalid values and write quick unit tests with ease!
• KameGMS --- Bring up TortoiseSVN and TortoiseGit dialogs from within the GMS IDE!
• JSOnion v1.1 --- The stink-free way to handle JSON! (even deeply nested ones)

### #13 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 20 March 2011 - 07:51 AM

GM understands strings and reals. Imaginary numbers don't properly exist; as any two numbers of the same type (positive or negative) will never be negative. 'i' was introduced as to allow mathematicians overcome this.

What? Imaginary numbers exist just as much as any other type of number. They come up because real numbers aren't "complete" in the sense that a polynomial with real coefficients may not have any real roots. With complex numbers this is not the case. A polynomial with complex coefficients always has at least one complex root (and, in fact, counting multiplicity there are exactly n roots for an order n polynomial). They have a number of other useful properties which help them unify a lot of methods in mathematics. As others have mentioned they do serve some use for geometrical operations among other things.

That said, I don't really think they serve enough of a purpose to include them as a specialized type.
• 0

### #14 paul23

paul23

GMC Member

• Global Moderators
• 4147 posts
• Version:GM:Studio

Posted 21 March 2011 - 02:14 PM

GM understands strings and reals. Imaginary numbers don't properly exist; as any two numbers of the same type (positive or negative) will never be negative. 'i' was introduced as to allow mathematicians overcome this.

What? Imaginary numbers exist just as much as any other type of number. They come up because real numbers aren't "complete" in the sense that a polynomial with real coefficients may not have any real roots. With complex numbers this is not the case. A polynomial with complex coefficients always has at least one complex root (and, in fact, counting multiplicity there are exactly n roots for an order n polynomial). They have a number of other useful properties which help them unify a lot of methods in mathematics. As others have mentioned they do serve some use for geometrical operations among other things.

That said, I don't really think they serve enough of a purpose to include them as a specialized type.

Also if "structures" would be possible in gamemaker, we can start to effectivelly extend the number of "datatypes".
• 0

Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

### #15 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 21 March 2011 - 07:02 PM

Also if "structures" would be possible in gamemaker, we can start to effectivelly extend the number of "datatypes".

• 0

### #16 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4355 posts
• Version:GM:Studio

Posted 22 March 2011 - 05:42 AM

If Mike and Russell added operator overloading to Game Maker, I would build a statue of them out of mashed potatoes.
• 5

### #17 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 22 March 2011 - 08:15 AM

Instead of putting in the coordinates as two arguments in a function, we can have the x coordinate as the real component and the y coordinate as the imaginary part

Wait, what? So instead of using 2 variables (x and y) to denote position in cardinal space...you want to use...2 variables (real and imaginary) to denote position in an off-the-wall space. How is that any more efficient? I especially ask this because last I checked, the monitor can only take x/y cardinal position...so you would still have to convert whatever formula you had through an algorithm to get it.

xshortguy shows us a rotation using imaginary math...but you would still have to convert it into and out of the imaginary space. How is THAT efficient over using the normal dot products and such?

I'm sorry if I sound daft when it comes to the 'i' world...but wtf is it needed for exactly in game making (that other more efficient forms of keeping it in realistic space can provide)? I can see this being used to possibly show mandelbrot sets (or the like), but I don't see how that relates to gaming (unless you are doing a "where's waldo" for the mini-bulb game -- yeah, that'll be popular among the kids).

If complex numbers are to be implemented into GM, I expect quaternions to be too

Awesome, so instead of 3 variables (x, y, z), you want 4 (r, i, j, k) or possibly more?

Imaginary numbers exist just as much as any other type of number

Only in the minds of those willing to believe they can square root a negative number. I think MoK was stating it more in a realistic sense, that imaginary numbers are not actually "tangable" but a way to reduce other forms of math by going through a somewhat wormhole (imaginary space). As far as I know, 'i' is not an integral part of any microprocessor, so any methods you want will have to be done in software anyway...TI may make it a point to do extensive software on advanced trig/calc/wtfever concepts for their calculator (because their target audience are those in need of them), but I seriously doubt YYG will put that much effort into a game making engine (which doesn't target the heavy math community directly).

I mean, it made sense to me...but what do I know, I'm only a simpleton.
• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #18 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 22 March 2011 - 12:49 PM

Imaginary numbers exist just as much as any other type of number

Only in the minds of those willing to believe they can square root a negative number.

In other words, in the minds of most educated people. Complex numbers are fundamental to every field of science and mathematics.

As far as I know, 'i' is not an integral part of any microprocessor

Nor is pi, e, or the square root of 2. So what does that have to do with it?

I'm not saying you're wrong about imaginary numbers not being critical for game making. But for god sakes, come up with some better arguments.

.

Edited by chance, 22 March 2011 - 12:50 PM.

• 0

### #19 MasterOfKings

MasterOfKings

The True Master

• GMC Member
• 4888 posts
• Version:GM8

Posted 22 March 2011 - 01:48 PM

@chance: Well, the square root of -1 didn't exist in earlier mathematics. They didn't just sit down and go "Oh my, what shall we do now?"; they made 'i'. Just because I said they don't properly exist; doesn't mean I think they're a waste of time. To a computer, trying to actual square root a negative number is impossible. We know otherwise.

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

Regardless, I'm not saying complex numbers shouldn't be included; but as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

-MoK
• 0

Did I help you? If so, help me by pressing the + button above here.

### #20 paul23

paul23

GMC Member

• Global Moderators
• 4147 posts
• Version:GM:Studio

Posted 22 March 2011 - 01:51 PM

@chance: Well, the square root of -1 didn't exist in earlier mathematics. They didn't just sit down and go "Oh my, what shall we do now?"; they made 'i'. Just because I said they don't properly exist; doesn't mean I think they're a waste of time. To a computer, trying to actual square root a negative number is impossible. We know otherwise.

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

Regardless, I'm not saying complex numbers shouldn't be included; but as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

-MoK

"0" didn't exist in mathematics neither, or negative number at all for that matter..
• 1

Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

### #21 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 22 March 2011 - 07:13 PM

...as most of people that use GM are kids who have never even heard of them; is it reasonable for YYG to include them?

No, it's not reasonable. My post made that clear. My comments were aimed at Sabriath's uninformed comments about the nature of complex numbers, not his view on whether GM needed them.

To a computer, trying to actual square root a negative number is impossible. We know otherwise.

That's false. Square root finders are software algorithms. And algorithms exist for complex numbers just as they exist for reals.

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

God that's dumb. Sorry, it's just... dumb. Do you think mathematical constants are "hard wired" into the silicon? lol....

.

Edited by chance, 22 March 2011 - 07:15 PM.

• 1

### #22 LSnK

LSnK

NaN

• GMC Member
• 1188 posts

Posted 22 March 2011 - 07:15 PM

And, um.. no one knows the final digit of pi (or e), so how do you expect someone to pre-program it into a micro-processor.

God that's dumb. Sorry, it's just... dumb.

You might even say it's irrational.
• 7

### #23 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 22 March 2011 - 08:05 PM

but you would still have to convert it into and out of the imaginary space

Such a conversion is trivial since you can easily access the real and imaginary parts of a complex number as easily as you can access the x and y coordinates of an object. In fact, representing rotations using complex numbers was so useful that someone decided to extend the complex numbers to quaternions which have really become the method for representing orientation in 3D...in 1843. And in that case you not only get i, but a j and k as well. While (as I've mentioned) I don't see much utility in adding complex numbers themselves (especially since they can be very easily implemented as two real variables), the addition of quaternions would be very useful, especially if they came with methods for their conversion into rotation matrices for use in 3D.

And algorithms exist for complex numbers just as they exist for reals.

In fact, the algorithms are mostly the same for complex numbers as they are for real numbers.

To a computer, trying to actual square root a negative number is impossible. We know otherwise.

To a computer, anything but a finite subset of the integers is impossible. And yet we somehow managed to make them operate on things resembling real numbers (technically a finite subset of rational numbers). To a computer everything is merely a logical manipulation of a set of bits.
• 1

### #24 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 22 March 2011 - 08:58 PM

In other words, in the minds of most educated people. Complex numbers are fundamental to every field of science and mathematics.

I am educated, I don't think about 'i' every second of my life. As for it being fundamental, ONLY to those fields, and those fields are worthless to humanity (except as hobby)...it's a fun escape from the real to find an abstract way to arrive at the same answer, but it is hardly a necessity of every day life. When a carpenter puts on a roof, he doesn't calculate square roots of negative numbers to arrive at a pitch (laymen)....up to the electronics designer who works with V=IR and other basic maths to determine circuit paths (and even then he uses SPICE which doesn't use 'i').

Although there are careers and fields of science out there that does make use of 'i', the question is are they getting anywhere? Wasting money to build a giant loop of coiled wires to watch atoms collide hasn't brought us flying cars or immortality (or anything useful except a bunch of papers written in the small community of scientists and hobbyists who care to read it).

Nor is pi, e, or the square root of 2. So what does that have to do with it?

God that's dumb. Sorry, it's just... dumb. Do you think mathematical constants are "hard wired" into the silicon? lol....

An FPU (now integrated with the CPU) as far back as pentium's first days (roughly) contains a command to load pi in the register, as for e and sqrt of 2, I haven't checked any of the new datasheets. But regardless, those are tangable values (although irrational, they are contained in the 'real' side of math). In order to use 'i', you would have to alter how the processor performs all it's math operations by checking if the NAN is an 'i' and resorting to complex arithmetic instead. Processors don't do this, so it's not native, which means it has to be built up in software instead (and again, forcing YYG to go that route is absurd).

No, it's not reasonable. My post made that clear. My comments were aimed at Sabriath's uninformed comments about the nature of complex numbers, not his view on whether GM needed them.

My position is that complex numbers are a thought and hobby venture more than practical. In that fact, it makes it useless in game making as well. Instead of voicing my opinion that GM doesn't need complex arithmetic and being shot down by those who have math backgrounds, I figured I would up the ante and show that it is practically useless altogether in life (kill the root and the veins starve).

That's false. Square root finders are software algorithms. And algorithms exist for complex numbers just as they exist for reals.

What? Square root is a processor command (on FPU), and when you do a square root of a negative number, you get a NAN error.

Such a conversion is trivial since you can easily access the real and imaginary parts of a complex number as easily as you can access the x and y coordinates of an object. In fact, representing rotations using complex numbers was so useful that someone decided to extend the complex numbers to quaternions which have really become the method for representing orientation in 3D...in 1843. And in that case you not only get i, but a j and k as well. While (as I've mentioned) I don't see much utility in adding complex numbers themselves (especially since they can be very easily implemented as two real variables), the addition of quaternions would be very useful, especially if they came with methods for their conversion into rotation matrices for use in 3D.

Show me the math that would be required in rotating a point (x,y,z) around an origin (ox,oy,oz) by a set degrees (dx, dy, dz) in both the real and complex way....then look and see which one the computer will do faster (has less operations).

In fact, the algorithms are mostly the same for complex numbers as they are for real numbers.

But for a human to write 'i' next to a calculation isn't as hard as it is for a computer to constantly check every single number that goes into a calculation on whether it is real or imaginary ("hard" in this sense is cycles wasted and a loss of a bit precision for storage).

To a computer, anything but a finite subset of the integers is impossible. And yet we somehow managed to make them operate on things resembling real numbers (technically a finite subset of rational numbers). To a computer everything is merely a logical manipulation of a set of bits.

Now you're just being silly.
• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #25 HaRRiKiRi

HaRRiKiRi

GMC Member

• GMC Member
• 1364 posts

Posted 22 March 2011 - 09:33 PM

sabriath: Im sorry, but you are so wrong in so many aspects that it just makes me sad understanding you are not a troll. If imaginary numbers are just for hobbist, then sorry, but Electronics use imaginary numbers A LOT. That's the basics of many transformations needed to calculate many aspects of the circuit. For example, no spectral analysis would be complete (or even useful) without taking complex parameters into account. The same is with almost every other aspect in electronics or any other field of science or technology. You seem like the kind of guy who thinks Pi is invented by man. So I doubt you can call yourself educated (at least in mathematics, physicist, electronics or any other field that has imaginary numbers).

What? Square root is a processor command (on FPU), and when you do a square root of a negative number, you get a NAN error.

You think all processor commands are magic? Two registers goes in and one comes out? Everything is done by algorithms. There isn't a logical element for sqrt(), so its usually expanded to a different equation. For example, sqrt can be written as , and now you can calculate it with logarithm (which also has a different algorithm which involves bit shiffting) and division by two which is also a bit shift. Basically, logical elements can only do addition, subtraction, multiplication by 2, division by 2 and inversion. Everything else is based on these elements. I once had a book which had algorithms for almost everything (sin, cos, log, ln, powers etc) done with these basic operations.

I don't even want to reply to the rest of your post.

Now you're just being silly.

I doubt you understood what he meant.

Edited by HaRRiKiRi, 22 March 2011 - 09:45 PM.

• 1

### #26 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 22 March 2011 - 10:13 PM

but Electronics use imaginary numbers A LOT

Where? I have never used them and I've designed and built a CPU from scratch (complete with rotary assignment, feedforward and back of registers, and pipelines with stalls).

For example, no spectral analysis would be complete (or even useful) without taking complex parameters into account

Oh, you mean waveform electronics, like SETI? Yeah, because that's important.

You seem like the kind of guy who thinks Pi is invented by man

Pi was invented by man. The fact that the circumference of a circle relates to its radius may not have been invented by man...but the number that was derived from those observations was.

So I doubt you can call yourself educated (at least in mathematics, physicist, electronics or any other field that has imaginary numbers).

You're right, I'm not educated....merely passing with the highest scores in both ap calc and physics in the district for at least 10 years prior and after and having the, pretty much, born knowledge of circuitry and programming is hardly educated. That's borderline mentally challenged right?

You think all processor commands are magic? Two registers goes in and one comes out? Everything is done by algorithms. There isn't a logical element for sqrt(), so its usually expanded to a different equation. For example, sqrt can be written as {f}, and now you can calculate it with logarithm (which also has a different algorithm which involves bit shiffting) and division by two which is also a bit shift. Basically, logical elements can only do addition, subtraction, multiplication by 2, division by 2 and inversion. Everything else is based on these elements. I once had a book which had algorithms for almost everything (sin, cos, log, ln, powers etc) done with these basic operations.

And? I'm sorry, but I don't see how that relates to me stating that "it is not native to the processor, so it would have to be built up in software" and "you lose 1 bit of precision and wasting time checking every number to make sure it's not imaginary before doing a calculation"? If complex numbers were THAT important, why doesn't intel, AMD and others build the next CPU with them native? I'm just not seeing the point that 'i' brings to the table where _other maths can be used to do the same thing_. As much as I love the beauty of mandelbrot and julia sets (and other fractals), to me, that's all they are...beauty, not practicality. They may have some coincidences (like logistic convergences), but again, just shows another way of doing math.

I doubt you understood what he meant.

I understood quite clearly...and I could have retorted with the fact that there is no actual "bit" in the machine either, it's actually just a build up of electrical energy on a small bit of metal which is continually recycled while releasing into other parts to allow even more electrical energy to either be blocked or pass. I didn't because I thought going that deep to create a strawman was silly, and I'm sure he knows it.
• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #27 HaRRiKiRi

HaRRiKiRi

GMC Member

• GMC Member
• 1364 posts

Posted 22 March 2011 - 11:32 PM

Where? I have never used them and I've designed and built a CPU from scratch (complete with rotary assignment, feedforward and back of registers, and pipelines with stalls).

You think CPU is basics of electronics? CPU is just a very small part of a very large field. What you did was just a combination logical elements which you later simulated in a program (because I am sure you didn't physically build it). Did you consider how these elements worked or how the simulation program worked?

Oh, you mean waveform electronics, like SETI? Yeah, because that's important.

Spectrums are the basics of analog electronics, signal transmission, filters and so on. There wouldn't be any mobile phones, satellites, wi-fi or anything else if people didn't understand spectrums. You are clearly not educated in much of electronics. You know only digital 1's and 0's and that is the reason why you don't know the significance of imaginary numbers. You are just as limited as the computers themselves. And if you have this cynical point of view on every human technological advancement then you don't also understand the basics of science as a whole.

Pi was invented by man. The fact that the circumference of a circle relates to its radius may not have been invented by man...but the number that was derived from those observations was.

May not have? Pi is a irrational number (thus infinite) and humans can't come up with something infinite. If a man invented pi then he would just make it 5 or something (or just 1) to make calculations easier. Pi is constant of 3.1415.. which is true in every part of the galaxy. Even aliens know pi and they have the same value for it. They of course will write it differently, but the value stays.

You're right, I'm not educated....merely passing with the highest scores in both ap calc and physics in the district for at least 10 years prior and after and having the, pretty much, born knowledge of circuitry and programming is hardly educated. That's borderline mentally challenged right?

_other maths can be used to do the same thing_.

And then why does CPU has instruction set for sqrt? Why can't we program it manually with "other maths"? As previously stated, things like quaternion are very useful in 3d graphics.
• 0

### #28 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 22 March 2011 - 11:54 PM

sabriath: Im sorry, but you are so wrong in so many aspects that it just makes me sad understanding you are not a troll.

Me too. It's embarrassing to see an adult make such a fool of himself. Reminds me of when I was a boy setting up my first circuit (boy scouts). I concluded that electrical engineering was nothing more that connecting the positive and negative terminals.

I guess it's human nature to underestimate the importance of things we don't understand.
• 1

### #29 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4355 posts
• Version:GM:Studio

Posted 23 March 2011 - 01:37 AM

Hi guys, let's avoid using personal attacks on people and only discuss imaginary numbers. The scope of the use of imaginary numbers in electric circuits is beyond the scope of the discussion on this forum. Head to another forum to continue that discussion.

With that said, the name imaginary is sort of a poor choice, since the construction of the complex numbers from the real numbers is quite a natural procedure. Without going into too many details, here are the highlights of the construction:

1. Start with the ring of polynomials with real coefficients R[x], i.e. things of the form $\sum a_i x^i$, for some indeterminate x.
2. Consider the ideal I, a subset of R[x], generated by x^2 + 1. One can show that this clearly isn't R[x], since one cannot form the polynomial x from it. Furthermore, one can show that I is a maximal ideal.
3. Since I is an ideal, we can take the quotient ring R[x]/I. Since I is a maximal ideal, R[x]/I is a field. Moreover, from the fundamental theorem of algebra, the degree of the field extension [R[x]/I : R[x]] is degree two, so R[x]/I has two basis elements: things of the form (0 + I) and things of the form (1 + I). The first is a real number since (0 + I)(0 + I) = 0 + 0I + 0I + II = 0 + 1 = -1. The latter is not a real number: (1 + I)(1 + I) = 1 + I + I + -1 = 2I. So numbers in this field are can be written in the form a (0 + I) + b (1 + I), where a, b are real numbers. With a bit of cleanup, we can relabel things as the form a + b i, where (0 + I) is our 1, and (1 + I) is our i.

The construction of forming new structures by quotient rings is typical in the subject of abstract algebra. Once you get a feel for this type of construction, you'll see that complex numbers are really just an extension of the real numbers that allows for solutions to given polynomials.
• 1

### #30 MasterOfKings

MasterOfKings

The True Master

• GMC Member
• 4888 posts
• Version:GM8

Posted 23 March 2011 - 05:35 AM

A processor works just like your brain. It gets a problem, it determines the best way around it, and it solves it. The square root of -1 is NOT a real; so it doesn't properly exist. Hence, the term imaginary. We can't define it as a number, hence 'i'.

May not have? Pi is a irrational number (thus infinite) and humans can't come up with something infinite. If a man invented pi then he would just make it 5 or something (or just 1) to make calculations easier. Pi is constant of 3.1415.. which is true in every part of the galaxy. Even aliens know pi and they have the same value for it. They of course will write it differently, but the value stays.

The existence of pi was not developed by man; however, pi isn't something that nature developed. The 'concept' (probably the wrong word) was developed by nature. Nature didn't call it pi; we did. And you have no right to speak for aliens, they might not even have discovered (or even use) the value.

Regardless, the value of complex numbers, here, is in it's use for GM and (basic) game making. In saying that, it's next to useless (mainly due to its audience).

Whether the processor can or cannot use them, is neither here nor there. The only point I made was that imaginary numbers don't actually exist. I never said they're useless to the world.

-MoK
• 0

Did I help you? If so, help me by pressing the + button above here.

### #31 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4355 posts
• Version:GM:Studio

Posted 23 March 2011 - 05:44 AM

The square root of -1 is NOT a real; so it doesn't properly exist. Hence, the term imaginary. We can't define it as a number, hence 'i'.

Stop using words that you clearly aren't understanding the meaning of, in this case "exists". The imaginary unit i exists in the same sense that any real number exists. Namely that each number is created in order to solve a particular type of problem from a well-defined set theoretic construction. For example, we invent natural numbers to solve the problem of associating quantities with objects. In this construction we can answer things such as 4 + x = 7. However one thing that we can't do with just natural numbers is that we can't answer a question such as 4 + x = 3. So in order to get around that, one can construct using equivalence relations--a well-defined method of doing so involving Cartesian products of natural numbers with clever equivalence relationships.

In the same manner, once we have real numbers we then have the question of for which x will x^2 + 1 = 0. It isn't hard to show that no such real number exists. However by doing a well-defined algebraic construction (cf Abstract Algebra) or by simply asserting that there is a quantity i such that i^2 = -1, we have created a new system capable of solving such a problem.

The terms "real" and "imaginary" are unfortunate terms that often confuse people; they are simply names kept for historical reasons that refer to specific collections of numbers.
• 0

### #32 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 23 March 2011 - 08:09 AM

You think CPU is basics of electronics? CPU is just a very small part of a very large field. What you did was just a combination logical elements which you later simulated in a program (because I am sure you didn't physically build it). Did you consider how these elements worked or how the simulation program worked?

No, I think CPU is a big part of everyday electronics, and the knowledge in it is tremendous in comparison to other areas. Although it boils down to 1's and 0's, there is still math involved that is not logical at all (as much as you think a gate passes the information clearly, there is drag on some parts, and the clock speed has to be just right to be able to catch them). I could go on, but why should I backpedal?

And yes, I did _build_ it myself...using the same litho methods that the big boys use, it was a hobby of mine when I was real young.

Spectrums are the basics of analog electronics, signal transmission, filters and so on. There wouldn't be any mobile phones, satellites, wi-fi or anything else if people didn't understand spectrums. You are clearly not educated in much of electronics. You know only digital 1's and 0's and that is the reason why you don't know the significance of imaginary numbers. You are just as limited as the computers themselves. And if you have this cynical point of view on every human technological advancement then you don't also understand the basics of science as a whole.

So you are saying that these "spectrums" cannot be shown in real world math? Because y=2.1844*sin(x) seems like a real wave to me, and subtracting it can filter out that "wavelength"....where exactly does the 'i' come in?

Can I get someone who is actually in a field that is useful to the human race and society to come forward and vouch that 'i' is used in their every day life? And actually show me where it applies that absolutely no other math can possibly be used other than imaginary math?

May not have? Pi is a irrational number (thus infinite) and humans can't come up with something infinite. If a man invented pi then he would just make it 5 or something (or just 1) to make calculations easier. Pi is constant of 3.1415.. which is true in every part of the galaxy. Even aliens know pi and they have the same value for it. They of course will write it differently, but the value stays.

The bold text is my point exactly. "Pi" <-- the word and it's constant in our lives is our invention...to an alien or any other creature, "pi" and "3.1415" may not have any meaning whatsoever to them.

And then why does CPU has instruction set for sqrt? Why can't we program it manually with "other maths"? As previously stated, things like quaternion are very useful in 3d graphics.

Because 'sqrt' is commonly used in everyday life, imaginary numbers are not as common. It's self-defined logic here, thought you would see that.

@xshortguy: Thanks for the explanation of the imaginary space....buuuuut...where does that fall in line with making 3D math "easier" or "more efficient"?

The only point I made was that imaginary numbers don't actually exist

+1 to that! I'm not being ignorant here, but I feel that you _cannot_ take the square root of a negative number. I understand that when used properly, you can come up with an answer that is in the real, like:

sqrt(-1) * sqrt(-1) = -1

Although you cannot take the sqrt of -1, the above formula is derived because you reduced the actual functioning (square or a sqrt is itself). To me, that doesn't make the imaginary space "exist", it just means that there is an identity shown and proven:

sqrt(A) * sqrt(A) = A

'i' is just used to show that this identity can be used at _some_ point later down the line in order to come up with an answer.

If I have '2i * 4' apples, how many do I have? ... exactly

Until you reduce any formula to get rid of any and all 'i' references (and its brethren j,k and others), then you do not have a 'real' number, only a partial answer with a function attachment.

Do not misread me though. I know that humans have invented all these forms of math and complex number arithmetic for our own purposes (and other species may have as well), but I am talking about the physical nature of the number and not the concept. Just like you cannot touch infinite (and spawns a whole other part of math I won't get into), you cannot touch imaginary numbers either....but when you bring certain parts together, the imaginary parts get reduced out (until then, I consider that 'not existing').

I have still not seen anyone produce to me the 3D mathematics that would show any plausibility for the need of these things in GM?

Edited by sabriath, 23 March 2011 - 08:11 AM.

• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #33 MasterOfKings

MasterOfKings

The True Master

• GMC Member
• 4888 posts
• Version:GM8

Posted 23 March 2011 - 10:21 AM

I admit I'm using the term 'exist' rather loosely. I was referring to them as an object (or whatever you want to call them) in the 'real' world. Sit down with a piece of paper and try to determine the square root of -1. You can through the world's supply of paper and you'll never reach the answer. Because it simply isn't possible. Now, this is where the whole 'imaginary' thing comes in. It replaces the square root of -1 with 'i'. This opens up a whole world of possibilities; most of which, a large number of people on this planet don't even understand.

They serve a purpose; but not one that exists in the 'real' world.

Please don't bite my head off and say that they do. I'll simply refer you to 'sit down with the paper' bit. YOU can't work out the square root of negative 1; so what makes you think that a computer can? Obviously, there's workarounds; it's those workarounds that built up this world as we know it.

Lastly, regardless of the uses of complex numbers; see them, not as they are, but what purpose they will serve in GM. You may claim they will be useful in 3D mathematics.. but GM is meant as a 2D game engine; what's the point in simplify 3D programming when, most of the time, we won't use it.

-MoK

PS: If you disagree, please don't combat it. Just ignore it. This fight has gone on long enough.

Edited by MasterOfKings, 23 March 2011 - 10:23 AM.

• 0

Did I help you? If so, help me by pressing the + button above here.

### #34 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 23 March 2011 - 11:03 AM

The scope of the use of imaginary numbers in electric circuits is beyond the scope of the discussion on this forum. Head to another forum to continue that discussion.

My comment was obviously NOT about the use of imaginary numbers in circuits. It was an example of how ignorance leads us to dismiss things we don't understand.

No, I think CPU is a big part of everyday electronics, and the knowledge in it is tremendous in comparison to other areas.
...
And yes, I did _build_ it myself...using the same litho methods that the big boys use

Another example of blissful ignorance. Manufacturing the semiconductor material that comprises the chips themselves, requires detailed understanding of quantum mechanics -- a field heavily dependent on mathematics in the complex plane. Yet you continue to pretend complex numbers are just an unnecessary curiosity.

...you cannot touch imaginary numbers either...

This seems to be the heart of your argument, and where you're the most confused. ALL mathematics concepts are conceptual. Can you touch the square root of 2? What about logarithms? Negative numbers?

Just because you're more familiar with natural number concepts, you think they're different somehow. More "real". They aren't.

And btw, stop asking people to prove the GM needs complex numbers. Nobody is saying that, so give up the straw dogs.

.

Edited by chance, 23 March 2011 - 11:06 AM.

• 1

### #35 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 23 March 2011 - 12:01 PM

Another example of blissful ignorance. Manufacturing the semiconductor material that comprises the chips themselves, requires detailed understanding of quantum mechanics -- a field heavily dependent on mathematics in the complex plane. Yet you continue to pretend complex numbers are just an unnecessary curiosity.

I didn't use quantum mechanics to do it....how do you come off telling me how I came up with my design and build? I'm sure I simply used a positive doped alloy and negative doped alloy, then coated continuously while shaving it flat, applying the next stain level and repeating the process. Where exactly in that process did you get quantum mechanics?

Did you mean the actual design phase, where I used simple gate logic pre-forms and reduced the entire process to a simple programming language that used nothing but those gates? That would look something like this:
//simple sr latch
q1265 = r nandp qn1265
qn1265 = s nandn q1265

I can tell you to 100% certainty that I did not use quantum mechanics at all, nor use the square root of a negative number.

This seems to be the heart of your argument, and where you're the most confused. ALL mathematics concepts are conceptual. Can you touch the square root of 2? What about logarithms? Negative numbers?

Yes, I can. Irrational numbers might have some precision issues, but they are tangable enough to make an effort at hitting the mark...for example, asking me to present the square-root of 2 from a piece of paper, I can cut out an area roughly equal to it (you cannot do that with 'i'). As for negative numbers, that's simply borrowing, if you say "draw me negative 2 circles," then I would turn to you and say "draw me 2 circles"....now they are negative by reverse....how about that 'i'...nope, still can't do that.

Just because you're more familiar with natural number concepts, you think they're different somehow. More "real". They aren't.
And btw, stop asking people to prove the GM needs complex numbers. Nobody is saying that, so give up the straw dogs.

I know the concepts of 'i', along with a lot of other areas in math. Just because I know it, doesn't mean I like it, nor think it's practical. As for wanting proof, I seriously just want to know because ever since highschool, I have not touched that crap for even 1 second...I want to know where it's useful in society, but more to the fact, I want to know how it relates to 3D math (because when I did 3D, I used basic dot-matrix transformations, I never heard of using imaginary numbers for it and want to see it in action...I'm curious now). If by that "proof" that it shows to be more efficient (which I personally don't believe it will be), then I will admit ignorance to the whole thing and bow into humbleness.
• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #36 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 23 March 2011 - 12:34 PM

I can tell you to 100% certainty that I did not use quantum mechanics at all, nor use the square root of a negative number.

That comment is like a draftsman saying "I didn't use the value of Pi to draw a circle. I just used a compass." lol...

You don't have to understand the principles, to use a recipe. You just have to follow directions. Your "CPU design" followed a recipe for semiconductors developed over decades of complex research, and whose properties can only be explained by quantum mechanics.

This seems to be the heart of your argument, and where you're the most confused. ALL mathematics concepts are conceptual. Can you touch the square root of 2? What about logarithms? Negative numbers?

Yes, I can. Irrational numbers might have some precision issues, but they are tangable enough to make an effort at hitting the mark...

You're confusing "tangible" with "familiar". For example, are you comfortable with the concept of a line (length, but no width)? What about a plane (length and width, but no depth)? They may seem familiar, but neither one truly occurs in nature. They are just mathematical constructs.

They are no more, and no less, "real" than complex numbers.
• 1

### #37 paul23

paul23

GMC Member

• Global Moderators
• 4147 posts
• Version:GM:Studio

Posted 23 March 2011 - 12:35 PM

Another example of blissful ignorance. Manufacturing the semiconductor material that comprises the chips themselves, requires detailed understanding of quantum mechanics -- a field heavily dependent on mathematics in the complex plane. Yet you continue to pretend complex numbers are just an unnecessary curiosity.

I didn't use quantum mechanics to do it....how do you come off telling me how I came up with my design and build? I'm sure I simply used a positive doped alloy and negative doped alloy, then coated continuously while shaving it flat, applying the next stain level and repeating the process. Where exactly in that process did you get quantum mechanics?

Did you mean the actual design phase, where I used simple gate logic pre-forms and reduced the entire process to a simple programming language that used nothing but those gates? That would look something like this:
//simple sr latch
q1265 = r nandp qn1265
qn1265 = s nandn q1265

I can tell you to 100% certainty that I did not use quantum mechanics at all, nor use the square root of a negative number.

You know, the whole fact you brought electronic engineering to this discussion weakens your points of imaginary numbers being useless? - One of the 'school book' examples of complex numbers is electrical engineering. Transistors, EM-fields, signal analys...

Just because you're more familiar with natural number concepts, you think they're different somehow. More "real". They aren't.
And btw, stop asking people to prove the GM needs complex numbers. Nobody is saying that, so give up the straw dogs.

I know the concepts of 'i', along with a lot of other areas in math. Just because I know it, doesn't mean I like it, nor think it's practical. As for wanting proof, I seriously just want to know because ever since highschool, I have not touched that crap for even 1 second...

You're working in the field of EE?

Anywhere I see a problem involving sine/cosine especially combined with integration/differentation I'd stop and ask myself the question: "shouldn't I be doing this with complex numbers instead".

Edited by paul23, 23 March 2011 - 04:11 PM.

• 0

Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

### #38 HaRRiKiRi

HaRRiKiRi

GMC Member

• GMC Member
• 1364 posts

Posted 23 March 2011 - 03:40 PM

I think discussion with sabriath is not very productive so I won't go any further. I have seen persons like that before (like carpenters who say why the heck someone needs a sqrt to calculate some diagonal.. just use a tape measure). All I can say is that he overrates himself as he clearly isn't as bright as he thinks he is.

Anyway, complex numbers in GM would be just like in C++. A structure with both the real and imaginary parts which can be used in calculations via special functions. The implementation itself wouldn't actually be that hard, but I believe they have bigger ideas.
• 0

### #39 FakeKraid

FakeKraid

Total Fraud

• GMC Member
• 66 posts
• Version:GM8

Posted 23 March 2011 - 05:02 PM

Irrelevant discussions of the 'reality' of imaginary or complex numbers aside, there have been some pretty fascinating answers to my question here. But, they raise another question. Why are programmers who are experienced and sophisticated enough to be working with planar rotations and complex data structures bothering with GM, with all its limitations, when they could be making their own engines in a more modern and efficient language? Or, to put that question in a positive way, so as to seem less confrontational, what exactly does GM have to offer a programmer of that level?

I mean, I'm using GM because I have NO programming experience whatsoever. I find that, even using GML exclusively, the things that the GM engine does for me bring otherwise unreachable levels of programming complexity within my admittedly limited reach. Someone with enough understanding of coding to be working with those rather esoteric things wouldn't see that as a benefit, though, would they?

I guess what I'm trying to say is, including imaginary/complex number functionality into GM seems like it would be a lot of trouble on the developers' part to add something that would only be useful to people who, if they really MUST have it, would be perfectly capable of going elsewhere to get it, or just making it themselves. Does that make sense?

Edited by FakeKraid, 23 March 2011 - 05:05 PM.

• 0

### #40 paul23

paul23

GMC Member

• Global Moderators
• 4147 posts
• Version:GM:Studio

Posted 23 March 2011 - 06:05 PM

Irrelevant discussions of the 'reality' of imaginary or complex numbers aside, there have been some pretty fascinating answers to my question here. But, they raise another question. Why are programmers who are experienced and sophisticated enough to be working with planar rotations and complex data structures bothering with GM, with all its limitations, when they could be making their own engines in a more modern and efficient language? Or, to put that question in a positive way, so as to seem less confrontational, what exactly does GM have to offer a programmer of that level?

I mean, I'm using GM because I have NO programming experience whatsoever. I find that, even using GML exclusively, the things that the GM engine does for me bring otherwise unreachable levels of programming complexity within my admittedly limited reach. Someone with enough understanding of coding to be working with those rather esoteric things wouldn't see that as a benefit, though, would they?

I guess what I'm trying to say is, including imaginary/complex number functionality into GM seems like it would be a lot of trouble on the developers' part to add something that would only be useful to people who, if they really MUST have it, would be perfectly capable of going elsewhere to get it, or just making it themselves. Does that make sense?

• 1

Extensions
(gex; GM:Studio)
Math, logic parser; Executing user inputted code in a complete safe manner (gex/script; GM:Studio)
Extended constants; (gex/script; all versions)

### #41 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 23 March 2011 - 07:00 PM

Why are programmers who are experienced and sophisticated enough to be working with planar rotations and complex data structures bothering with GM, with all its limitations, when they could be making their own engines in a more modern and efficient language?

Plenty of members here are capable of that. If they truly need something better, they can build it. But if GM does what they want, why spend time/effort developing something else?

Tailors don't necessarily make all their own clothes. Not every carpenter builds his own home.

...including imaginary/complex number functionality into GM seems like it would be a lot of trouble on the developers' part to add something that would only be useful to people who, if they really MUST have it, would be perfectly capable of going elsewhere to get it...

Or they can build their own complex number system within GM. Either way, nobody here is saying GM really needs complex numbers, although a few have suggested some applications. I think we all agree on that.
• 0

### #42 HaRRiKiRi

HaRRiKiRi

GMC Member

• GMC Member
• 1364 posts

Posted 23 March 2011 - 07:03 PM

Or, to put that question in a positive way, so as to seem less confrontational, what exactly does GM have to offer a programmer of that level?

Speed of development? GM is flexible enough and good enough to allow any 2d game or application to be made. I actually create more programs in GM than games. I have some experience with C++ and OpenGL and I just don't want to waste 2 days just to make the very basics of the program. In GM I can have a working prototype 3 days after beginning of the development and ready program about a week later. That is why people who have experience in other languages use GM a lot. Now when GM can run on many platforms it is almost stupid to make games in any other development tool.
• 0

### #43 FakeKraid

FakeKraid

Total Fraud

• GMC Member
• 66 posts
• Version:GM8

Posted 23 March 2011 - 10:13 PM

Speed of development? GM is flexible enough and good enough to allow any 2d game or application to be made. I actually create more programs in GM than games. I have some experience with C++ and OpenGL and I just don't want to waste 2 days just to make the very basics of the program. In GM I can have a working prototype 3 days after beginning of the development and ready program about a week later. That is why people who have experience in other languages use GM a lot. Now when GM can run on many platforms it is almost stupid to make games in any other development tool.

Ah, I see. I had no idea GM was that generally useful. I mean, it's certainly been a great help to me, but I didn't realize it was that good. That makes me feel better about using it. (:

Plenty of members here are capable of that. If they truly need something better, they can build it. But if GM does what they want, why spend time/effort developing something else?

Tailors don't necessarily make all their own clothes. Not every carpenter builds his own home.

I sort of had a feeling that might be the case, but I wanted to ask anyway.

Edited by FakeKraid, 23 March 2011 - 10:19 PM.

• 0

### #44 Gamer3D

Gamer3D

Human* me = this;

• GMC Member
• 1819 posts
• Version:GM:Studio

Posted 24 March 2011 - 06:48 AM

Ah, I see. I had no idea GM was that generally useful. I mean, it's certainly been a great help to me, but I didn't realize it was that good. That makes me feel better about using it. (:

It's not that it's that good. It uses a slow interpreter, has important parts of it programmed naively, and doesn't have many advanced language features.

I use it because it doesn't need much effort. If I want to create something that works fast, I'll do it in C++.

Anyway, back to the topic at hand:
• Pros of implementing complex numbers: Easier computation of roots of cubic/quartic equations, some other computations.
• Cons: Adding the proper constant i would break scripts that use that to increment (I use i as a temporary variable every so often) and would break many extensions, specifically the ones that use GMAPI and my priority queues, which would then be receiving a different input for the same variables. Ambiguities would also occur. For example, is (2 - i > 1)? Extra checks before functions such as graphics would slow GM (though not significantly, because all GM function calls are already slow) as would the additional calculations every time a variable is multiplied/added/subtracted/divided/square-rooted/exponentiated/sined/cosined/tangented/etc.

In short, the disadvantages, especially the ambiguity problem, make this not worth putting into Game Maker and in fact make it worthwhile to avoid adding this.

[sarcasm]Also, if we add complex numbers, why stop there? Quaternions would be nice. Same disadvantages as before (and more), but could simplify those 8 calculations where they are used.[/sarcasm]
• 0
Fast Priority Queues - Game Maker's priority queues are O(n). Mine do everything that Game Maker's do, but in O(log n) time.
Dual-Quaternion Skinning - Modifying vertexes in GM is slow. This simple vertex shader does the job both quickly and well.

### #45 xshortguy

xshortguy

GMC Member

• Global Moderators
• 4355 posts
• Version:GM:Studio

Posted 24 March 2011 - 09:11 AM

Ambiguities would also occur. For example, is (2 - i > 1)?

There's no ambiguity there. The complex numbers don't have that partial ordering relationship.

One can use the capital letter I for imaginary numbers, or even a delimiter such as ~. A + ~B = A + BI. However, it would make more sense to simply add a struct to do this.

Also, if we add complex numbers, why stop there? Quaternions would be nice. Same disadvantages as before (and more), but could simplify those 8 calculations where they are used.

I wish there would be native support functions for both matrices and quaternions, because they are very useful. They won't be inline such as a + b*i + c*j + d*k, but rather like classes in C++.
• 1

### #46 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 24 March 2011 - 09:17 AM

Ambiguities would also occur. For example, is (2 - i > 1)?

That's no more ambiguous than "cat" > 4. The complex numbers are not an ordered field, so it's meaningless to try to compare them.

Extra checks before functions such as graphics would slow GM (though not significantly, because all GM function calls are already slow)

You mean the same checks that GM already performs to make sure you're not passing in a string?

as would the additional calculations every time a variable is multiplied/added/subtracted/divided/square-rooted/exponentiated/ sined/cosined/tangented/etc.

How is this relevant? The data type is more computationally expensive, yes, but that doesn't matter since we're not using it instead of existing data types. We'd be using it in situations that the real numbers simply can't handle period. The fact that complex numbers would be slower in cases where you wouldn't use complex numbers is a non-sequitur.

Also, if we add complex numbers, why stop there? Quaternions would be nice. Same disadvantages as before (and more), but could simplify those 8 calculations where they are used.

Oh look, another person who's never tried to handle rotations in 3D and especially never tried to handle integrating the equations of motion of a rigid body in 3D (which is really about the simplest rotation model you can get). Quaternions are computationally less expensive, take up less space, and are more numerically stable than representing rotations in matrix form. Oh, and remember off the top of your head how to construct a rotation matrix based on an axis and an angle? Probably not, since it's non-trivial. Fortunately that's another thing quaternions happen to be really good at. Hell, they even make it easy to smoothly rotate from one orientation to another without hitting any of the nasty singularities you get from other representations (which also cause that whole nasty gimbal lock issue).
• 2

### #47 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 24 March 2011 - 01:04 PM

Oh look, another person who's never tried to handle rotations in 3D and especially never tried to handle integrating the equations of motion of a rigid body in 3D (which is really about the simplest rotation model you can get). Quaternions are computationally less expensive, take up less space, and are more numerically stable than representing rotations in matrix form. Oh, and remember off the top of your head how to construct a rotation matrix based on an axis and an angle? Probably not, since it's non-trivial. Fortunately that's another thing quaternions happen to be really good at. Hell, they even make it easy to smoothly rotate from one orientation to another without hitting any of the nasty singularities you get from other representations (which also cause that whole nasty gimbal lock issue).

Given a quaternion formula of z=a+bi+cj+dk, where |z|=1, the normal representation of that rotation matrix in real math would be:

[[a^+b^-c^-d^, 2bc-2ad,     2bd+2ac    ]
[2bd-2ac,     2cd+2ab,     a^-b^-c^+d^]]

where '^' means squared

I will agree that it takes less space in a rotational form....but how would you calculate z=a+bi+cj+dk on a computer so that you move a rigid body to its next destination? By...using the matrix above? So you save variable space for all of a microsecond just to put it through the above calculation anyway?

Besides that, the above calculation was just to turn quaternion into orthogonal space....a rotation inside that space first without going the quaternion route doesn't yield as much complexity, it's simply:

rotation around x

[[ 1,      0,      0     ]
[ 0,      cos(a), sin(a)]
[ 0,     -sin(a), cos(a)]]

rotation around y

[[ cos(a), 0,     -sin(a)]
[ 0,      1,      0     ]
[ sin(a), 0,      cos(a)]]

rotation around z

[[ cos(a), sin(a), 0     ]
[-sin(a), cos(a), 0     ]
[0,       0,      1     ]]

Rotating around an arbitrary line, you simply normalize the vector (another matrix) and apply as such. You already get the answer right away, rather than having to use the previous transformation JUST to get out of quaternion calculations in order for the computer to get a physical x/y location to draw to.

This all seems moot anyway since d3d can do transformations for you, orthogonally, can't it? Or did I just imagine d3d_transform_set_rotation_* functions? *shrugs* oh well, I'm stupid!

edit: and about gimbal lock, who cares? If a rigid body is hit on its side to rotate around its x-axis, then gets hit again to move about the y-axis...and a third time to move around the z-axis, then it would properly rotate as per physics rules without violation of any laws, even if it "seems" to lock on a plane for 2 rotations at a time every 10 or so. That's normal for all I care, not seeing a downside here.

Edited by sabriath, 24 March 2011 - 01:13 PM.

• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #48 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 24 March 2011 - 08:08 PM

will agree that it takes less space in a rotational form....but how would you calculate z=a+bi+cj+dk on a computer so that you move a rigid body to its next destination?

To rotate about an axis <u, v, w> by angle a, the quaternion is given by <cos(a/2), sin(a/2) u, sin(a/2) v, sin(a/2) w>. I don't know how you managed to look up conversion to a rotation matrix without also looking up this formula. And if you don't want to resort to converting to a rotation matrix (and instead use quaternions all the way through), you represent a vector as a quaternion, v, with 0 real part and then perform the rotation this way:

v' = q v q-1

Where q is the quaternion representing the rotation. Converting to a matrix, especially if you have to transform a lot of points (for example in the case of a rigid body) would be cheaper.

You're also ignoring a large number of the advantages I mentioned. For example, numerical stability. Because of rounding errors matrix multiplication can result in a transformation matrix that is no longer orthogonal and it's not trivial to orthogonalize a matrix so that it still represents an appropriate rotation. Quaternions don't suffer from this problem since they can be trivially normalized and unit quaternions *always* represent a valid rotation.

You also didn't give a rotation matrix representing a rotation about an arbitrary axis.

You also seem to think that you'd use quaternions to represent a single simple rotation and that's not what you'd do. Like I said, they simplify the representation of an object's orientation which is useful when it's time varying (as in the case of rigid bodies or cameras that need to rotate smoothly from one orientation to another).

a rotation inside that space first without going the quaternion route doesn't yield as much complexity, it's simply:

Which is an Euler angle representation which suffers from gimbal lock since it doesn't represent a unique rotation.

That's normal for all I care, not seeing a downside here.

That's because you don't know what you're talking about. Gimbal lock wouldn't be a problem provided you integrated the rotational equations of motion in such a way that it wasn't.
• 2

### #49 sabriath

sabriath

12013

• GMC Member
• 3197 posts

Posted 24 March 2011 - 09:56 PM

@Yourself: You provided the methods on which to rotate in the u,v,w space, which is not known to the computer....you still have rounding errors not only in that space, but when converting to the x,y,z so that the computer can actually display it on a monitor. Rounding errors will always be apparent in any system because it is just not feasable to be storing an infinite amount of decimal places, so why bring that up?

As for the matrix, you are calculating it ahead of time, once all the transformations have been completed, you only have 1 matrix with 1 set of values finished (until a new transformation must be applied). In quaternion, whenever you actually finish with all those calculations, you still have to apply the first complex matrix to the equation in order to switch it into x,y,z space....for every point.

Don't understand what I mean? Ok...let's say that there is a camera in 3D at the origin pointing toward (0,0,1), and there is a point located at (1,1,15). Find the matrix that would apply a rotation around the line that passes through points (0,0,0) and (1,2,3) as well as the quaternion representation, this will represent the "space" taken up by the system. I have already agreed that quaternion does take up less space.

Now show the algorithms to actually apply the above calculations in order to display this to the "camera" (screen) that has a 800x600 display and a 4 foot viewing distance. I'm willing to bet that the matrix will beat the quaternion in efficiency here, but since the only thing I have to go on is that first complex matrix I showed, I have no reason to think otherwise....until someone shows me (as I have stated from the beginning).

That's because you don't know what you're talking about

Then why don't you actually provide something to show how I'm wrong, rather than just stating I'm wrong? I've provided formulas at least, and the only other formulas provided were in an imaginary space. Last time I checked, a graphics card can't display imaginary space unless you transform it....or did ATI come up with a way to open a rift in spacetime?
• 0

Tutorials of Interest:
* Multiplayer: mine or True Valhalla's

Projects:
* Net39
* My 39dll scripts
* My 39dll lib
* Multiplayer Engine
* Artificial Chemistry

### #50 chance

chance

GMC Member

• Global Moderators
• 8762 posts
• Version:GM:Studio

Posted 24 March 2011 - 11:18 PM

That's because you don't know what you're talking about

Then why don't you actually provide something to show how I'm wrong, rather than just stating I'm wrong?

Because he'd be wasting his time. You're arguing against something that's proven and widely accepted by mathematicians and CG programmers for decades.

It's like you're demanding proof that Earth is round. Why should anyone bother?
• 1