# Imaginary Numbers

120 replies to this topic

### #31 xshortguy

xshortguy

GMC Member

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

Posted 23 March 2011 - 05:30 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
• 3189 posts

Posted 23 March 2011 - 07:55 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 - 07:57 AM.

• 0

### #33 MasterOfKings

MasterOfKings

The True Master

• GMC Member
• 4888 posts
• Version:GM8

Posted 23 March 2011 - 10:07 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:09 AM.

• 0

### #34 chance

chance

GMC Member

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

Posted 23 March 2011 - 10:49 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 - 10:52 AM.

• 1

### #35 sabriath

sabriath

12013

• GMC Member
• 3189 posts

Posted 23 March 2011 - 11:47 AM

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

### #36 chance

chance

GMC Member

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

Posted 23 March 2011 - 12:20 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
• 3918 posts
• Version:GM:Studio

Posted 23 March 2011 - 12:21 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 - 03:57 PM.

• 0

### #38 HaRRiKiRi

HaRRiKiRi

GMC Member

• GMC Member
• 1364 posts

Posted 23 March 2011 - 03:26 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
• 58 posts
• Version:GM8

Posted 23 March 2011 - 04:48 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 - 04:51 PM.

• 0

### #40 paul23

paul23

GMC Member

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

Posted 23 March 2011 - 05:51 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

### #41 chance

chance

GMC Member

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

Posted 23 March 2011 - 06:46 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 - 06:49 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
• 58 posts
• Version:GM8

Posted 23 March 2011 - 09:59 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:05 PM.

• 0

### #44 Gamer3D

Gamer3D

Human* me = this;

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

Posted 24 March 2011 - 06:34 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

### #45 xshortguy

xshortguy

GMC Member

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

Posted 24 March 2011 - 08:57 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:03 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
• 3189 posts

Posted 24 March 2011 - 12:50 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 - 12:59 PM.

• 0

### #48 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 24 March 2011 - 07:54 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
• 3189 posts

Posted 24 March 2011 - 09:42 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

### #50 chance

chance

GMC Member

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

Posted 24 March 2011 - 11:04 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

### #51 sabriath

sabriath

12013

• GMC Member
• 3189 posts

Posted 25 March 2011 - 12:12 AM

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?

No I'm not....because I use to work with 3D math all the time, and NEVER used quaternions. I didn't even know about them being viable until this topic even existed, and I am _seriously_ curious as to how it would be even possible. I want to see it in action, so that I can better judge its efficiency on a system.

I have not been provided with it, so I will continue to assume that matrices are better. I would have thought that if quaternions were better, that graphics cards would contain them? Or am I wrong there too...because I sure can't find any API directly connecting them to the system (then again, there are thousands of functions to sift through, so I may have overlooked them). Feel free to speak up, because again, I'm curious.
• 0

### #52 Rusky

Rusky

GMC Member

• GMC Member
• 2492 posts

Posted 25 March 2011 - 03:50 PM

You do realize a complex number would be represented in the machine exactly the same way as an x/y pair, right?
• 0

### #53 chance

chance

GMC Member

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

Posted 25 March 2011 - 04:42 PM

I am _seriously_ curious as to how it would be even possible. I want to see it in action, so that I can better judge its efficiency on a system.

I assumed you were dismissing the usefulness of quaternion rotations, just as you dismissed the usefulness of complex numbers earlier in this topic.

But if you're serious about wanting to understand them, there's tons of sites that explain how to use them. Just Google "quaternion rotation". If you already understand the mathematics of general rotation matrices, you won't have any trouble understanding quaternion rotation.
• 0

### #54 Smiley Showdown

Smiley Showdown

GMC Member

• New Member
• 10 posts

Posted 03 April 2011 - 05:38 PM

I understand that this debate is fun and all, but what i want to know is what this will be used for and what implications it has for programming, NOT a debate about the viability/importance of imaginary numbers. These forums are intended to be used for GM discussions, not math debates.
• 0

### #55 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 03 April 2011 - 06:35 PM

but what i want to know is what this will be used for and what implications it has for programming

• 0

### #56 DerrenFreeman

DerrenFreeman

GMC Member

• New Member
• 16 posts

Posted 01 May 2011 - 06:21 PM

I am not here to comment on the usefulness or validity of complex numbers or quaternions, (although I do believe they are both valid and useful), and I am just here to state the following quote.

Neither Complex Numbers or Quaternions would be useful to the average GML user, however, if one is educated, and curious enough, to want or use them, then they are educated and curious enough to be able to implement such ideas into Game Maker by themself. Because of this, I contend it would be a waste of time, and (arguably) processing power, to natively input them into Game Maker.

-Derren Freeman

Yes, I am quoting myself, and please feel free to quote it again.
• 0

### #57 Gamer3D

Gamer3D

Human* me = this;

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

Posted 01 May 2011 - 08:59 PM

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.

So I used the wrong term. You noticed. Congratulations.

I guess I've been assuming that complex numbers would replace the current variables. At some point, some noob is bound to try to compare 2 complex numbers.

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?

Fair enough. Doesn't invalidate what I said though.

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.

With the problem here being that 2% of Game Maker games would actually benefit from this...
This goes along with my assumption that to add complex numbers, YoYo would just add another double to the current variable scheme and change some functions.

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).

Actually, I have used quaternions. Often. They take up less space than the corresponding 3x3 matrix, can be normalized more easily, and their multiplication has fewer operations than a corresponding 3x3 matrix multiplication. They do take more operations to rotate a vector though.

I was trying to raise the question of how much should be implemented as a permanent feature of GM. Complex numbers are infinitely useful, but probably won't be needed often enough in the 2D platformers that GM caters to.

I should have use octonians as my example of something that Game Maker doesn't need.

No I'm not....because I use to work with 3D math all the time, and NEVER used quaternions. I didn't even know about them being viable until this topic even existed, and I am _seriously_ curious as to how it would be even possible. I want to see it in action, so that I can better judge its efficiency on a system.

I have not been provided with it, so I will continue to assume that matrices are better. I would have thought that if quaternions were better, that graphics cards would contain them? Or am I wrong there too...because I sure can't find any API directly connecting them to the system (then again, there are thousands of functions to sift through, so I may have overlooked them). Feel free to speak up, because again, I'm curious.

Matrices have their place. As do quaternions. When it comes to rotating vectors (for example, the vertices in a mesh), then matrices are more efficient. If you want to make sure that your spatial representation doesn't gradually stop being a rotation due to round-off error, then quaternions are a good way to go. If you need both, a hybrid approach is often most useful (use quaternions, then create a matrix when multiple point rotations are needed).

You don't NEED to work with quaternions. It's just more efficient in many cases.

Also, I know this was on page 2, but

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.

Draw me a square of area -1. The sides are now i, because forming a square with those sides will yield an area of -1.
• 0

### #58 sabriath

sabriath

12013

• GMC Member
• 3189 posts

Posted 01 May 2011 - 09:43 PM

Draw me a square of area -1

And how am I suppose to do that? "-1" in hypothetical terms is the same as "borrowing," so if I borrow 1 piece of paper from you, than you have '-1' pieces of paper. If the paper were square, then one edge would still be '1', not 'i' because it's like -sqrt(1) in the same hypothetical sense. There's no actual way to "draw" or come up with a way to physically show sqrt(-1).

This is all moot now, Yourself and others have put forth their all-knowing opinions on the situation. Although I do not agree (because I still haven't been shown, nor found any documentation on how it simplifies anything since no computer monitor takes in quaternion calculations as an input to derive a pixel position), it really doesn't matter because they know more than me in the mathematics area.
• 0

### #59 xshortguy

xshortguy

GMC Member

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

Posted 01 May 2011 - 09:55 PM

A square of area -1 is the same as a square of area 1, except the "orientation" is different. (Areas can have a sense of orientation.)
• 0

### #60 Gamer3D

Gamer3D

Human* me = this;

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

Posted 01 May 2011 - 11:34 PM

Draw me a square of area -1

And how am I suppose to do that? "-1" in hypothetical terms is the same as "borrowing," so if I borrow 1 piece of paper from you, than you have '-1' pieces of paper. If the paper were square, then one edge would still be '1', not 'i' because it's like -sqrt(1) in the same hypothetical sense. There's no actual way to "draw" or come up with a way to physically show sqrt(-1).

So your "negative circles" argument is invalid. If you ever get a chance, take a course in abstract algebra. Near the end, you will encounter a proof that the complex numbers are algebraically closed (I.E. every polynomial with complex coefficients has complex roots).

This is all moot now, Yourself and others have put forth their all-knowing opinions on the situation. Although I do not agree (because I still haven't been shown, nor found any documentation on how it simplifies anything since no computer monitor takes in quaternion calculations as an input to derive a pixel position), it really doesn't matter because they know more than me in the mathematics area.

It simplifies:
• Memory. Quaternion takes 4 times what a scalar takes, equivalent matrix takes 9.
• Multiplication: Quaternion multiplication is 28 scalar operations. Matrix is 45.
• Normalization. Quaternion takes 1 sqrt, 4 divisions. Matrix takes more, with the exact number depending on the method.
So basically it's a good way to handle rotations of an object. Once you want to rotate multiple vectors though, it's best to get a matrix from it and use that.
• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users