• Create Account

# What type of programs can I work on to apply Linear Algebra concepts

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

13 replies to this topic

### #1warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 18 December 2013 - 06:13 PM

I just finished my Linear Algebra final. It was very computation heavy like the previous exams but nothing that screams "this is impossible". First time taking Linear Algebra.

Now that I finished my studies. May anyone point me to what type of stimulation or games I can work on that uses a lot of the concepts from Linear Algebra?

Anyone of the games use a function that needs to find a determinant of a matrix or find the eigenvalues or eigenvectors of a given matrix or even use the Gram Schmidt process or needs to compute an inverse of a matrix or heck even use the P*P^-1?

I really want to start this journey given my background in Linear Algebra.

By the way does the application have to be in 3D?

I have background programming simple 2D games so I want to apply linear algebra to 2D games if possible. If not, you can list 3D applications.

Edited by warnexus, 18 December 2013 - 08:55 PM.

### #2EarthBanana  Members   -  Reputation: 668

Like
0Likes
Like

Posted 18 December 2013 - 07:19 PM

Linear algebra is very useful for transforming coordinate systems...

in shaders you multiply 4d vectors representing vertex positions by a matrix to transform that vertex coordinates in to 2d screen space.. its called a projection matrix.. you can also use matrices to represent orientations/scalings/positions of an object in some coordinate system and use that matrix to transform other objects to the same coordinate system...

ie object1Pos = (x,y,z,w)

object1NewPos = object2TransformMatrix * object1Pos

This can be used just as well in 2d as it can in 3d - when you start using shaders in your rendering you will likely be using matrices a lot for transforming coordinate spaces

Also - the inverse matrix can be used to sort of go back... I used an inverse of the projection matrix to map 2d mouse movements to a 3d space

### #3Irlan  Members   -  Reputation: 694

Like
0Likes
Like

Posted 18 December 2013 - 08:21 PM

I'm going to give you a brief review:

Transform Matrix = Coordinate System. Every Game Object has at least one.

Matrices have one objective (in practice): put vectors in another Coordinate System (a new scaled/rotated/translated system) etc.
The origin of the Coordinate System of your Scene Node doesn't exist (actually exist, is the Identity Matrix, but you've didn't any transformation from the point that was created)

Matrices that I've used most so far:

Transform/Model/World Matrix (scale/rotate/translate my player)
View Matrix (put a Enemy to face the player given a eye position and a target position)
Projection (render something like a hologram)

Good Luck! I hope that you've understood a little (and my words too).

### #4warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 18 December 2013 - 09:02 PM

Linear algebra is very useful for transforming coordinate systems...

in shaders you multiply 4d vectors representing vertex positions by a matrix to transform that vertex coordinates in to 2d screen space.. its called a projection matrix.. you can also use matrices to represent orientations/scalings/positions of an object in some coordinate system and use that matrix to transform other objects to the same coordinate system...

ie object1Pos = (x,y,z,w)

object1NewPos = object2TransformMatrix * object1Pos

This can be used just as well in 2d as it can in 3d - when you start using shaders in your rendering you will likely be using matrices a lot for transforming coordinate spaces

Also - the inverse matrix can be used to sort of go back... I used an inverse of the projection matrix to map 2d mouse movements to a 3d space

Ah shaders that means I need to learn OpenGL.

### #5warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 18 December 2013 - 09:28 PM

I'm going to give you a brief review:

Transform Matrix = Coordinate System. Every Game Object has at least one.

Matrices have one objective (in practice): put vectors in another Coordinate System (a new scaled/rotated/translated system) etc.
The origin of the Coordinate System of your Scene Node doesn't exist (actually exist, is the Identity Matrix, but you've didn't any transformation from the point that was created)

Matrices that I've used most so far:

Transform/Model/World Matrix (scale/rotate/translate my player)
View Matrix (put a Enemy to face the player given a eye position and a target position)
Projection (render something like a hologram)

Good Luck! I hope that you've understood a little (and my words too).

When you mean scale do you mean you are enlarging a 2D sprite or a 3D model to be of small or larger size than its normal size?

I understanding the rotate. You can change the angle of where the object is facing.

What I don't get is the translate. What do you mean by translate the player?

Edited by warnexus, 18 December 2013 - 09:29 PM.

### #6Key_46  Members   -  Reputation: 307

Like
1Likes
Like

Posted 18 December 2013 - 10:08 PM

The machine learning, computer vision, data mining are field is full of linear algebra, and so Facebook, Google and Twitter are also full of linear algebra.

### #7arka80  Members   -  Reputation: 423

Like
0Likes
Like

Posted 19 December 2013 - 02:29 AM

What I don't get is the translate. What do you mean by translate the player?

it simply means moving the player to another position in relations to every other scene object, or simply the world... Think of it like a change of position

### #8Irlan  Members   -  Reputation: 694

Like
0Likes
Like

Posted 19 December 2013 - 07:19 AM

I'm going to give you a brief review:

Transform Matrix = Coordinate System. Every Game Object has at least one.

Matrices have one objective (in practice): put vectors in another Coordinate System (a new scaled/rotated/translated system) etc.
The origin of the Coordinate System of your Scene Node doesn't exist (actually exist, is the Identity Matrix, but you've didn't any transformation from the point that was created)

Matrices that I've used most so far:

Transform/Model/World Matrix (scale/rotate/translate my player)
View Matrix (put a Enemy to face the player given a eye position and a target position)
Projection (render something like a hologram)

Good Luck! I hope that you've understood a little (and my words too).

When you mean scale do you mean you are enlarging a 2D sprite or a 3D model to be of small or larger size than its normal size?

I understanding the rotate. You can change the angle of where the object is facing.

What I don't get is the translate. What do you mean by translate the player?

Well, I'm going to take a piece of code of my Software.

void Entity::Update(float dt)
{
position += velocity * dt;

transform = Matrix44(); //reset to identity

//scale
transform.m11 = scale.x;
transform.m22 =  scale.y;
transform.m33 = scale.z;

//rotate
transform = transform * rotation;

//translate
transform.m41 = position.x;
transform.m42 = position.y;
transform.m43 = position.z;
}
Note that you could do a Scale, Rotation, a Translation Matrix and multiply all together Transform = (S * R * T) because one will transform another in the sequence.
But to be fast, we can reset the matrix, set the scale, multiply by the rotation (the currently is the scale) and set the translation. Note that the Matrices are in Row Major Order.

If you want to understand the concepts you MUST write your own Algebra Library (Vector, Matrix).
After, you can play like a video-game. Put a camera position behind the player (multiplying a offset with the player's transform), make enemies face the player (View Matrix) or do orthographic projections like those clips that we see on Dead Space's cut scenes (Projection Matrix).
3D Rotations are very different from the 2Ds because there are 3 axis. In 2D with one angle you can describe the player's rotation. In 3D you'll need the Euler Angles. I don't recommend to extract a rotation matrices from those angles. Instead, keep doing rotation changing when it's needed it and later extract the angles.
With a decent knowledge of matrices you can do everything like: writing a Graphics/Physics Engine, Collision Methods, etc.

So WORTH a lot to studying that.

### #9Kaptein  Prime Members   -  Reputation: 1353

Like
0Likes
Like

Posted 19 December 2013 - 07:29 AM

Linear algebra is very useful for transforming coordinate systems...

in shaders you multiply 4d vectors representing vertex positions by a matrix to transform that vertex coordinates in to 2d screen space.. its called a projection matrix.. you can also use matrices to represent orientations/scalings/positions of an object in some coordinate system and use that matrix to transform other objects to the same coordinate system...

ie object1Pos = (x,y,z,w)

object1NewPos = object2TransformMatrix * object1Pos

This can be used just as well in 2d as it can in 3d - when you start using shaders in your rendering you will likely be using matrices a lot for transforming coordinate spaces

Also - the inverse matrix can be used to sort of go back... I used an inverse of the projection matrix to map 2d mouse movements to a 3d space

Ah shaders that means I need to learn OpenGL.

Sure, unless you are specifically interested only in the math.

You can draw to a 2D screen using nothing but code, math and a good attitude. It won't be the most elegant or desirable solution, but so what?

There are many interesting things you can do once you are able to just get a window up and draw to it, such as drawing primitives and animating them using bones and constraints. It doesn't have to be very complicated.

Either way, if you really want to work with graphics, you'll want to learn OpenGL, which consists of this:

10% setting up

20% understanding how opengl renders to the screen (aka what is a rasterizer)

80% math

and yes, this adds up to 110%

### #10warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 19 December 2013 - 09:16 AM

What I don't get is the translate. What do you mean by translate the player?

it simply means moving the player to another position in relations to every other scene object, or simply the world... Think of it like a change of position

Oh I get it now! Thanks!

### #11warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 19 December 2013 - 09:25 AM

I'm going to give you a brief review:

Transform Matrix = Coordinate System. Every Game Object has at least one.

Matrices have one objective (in practice): put vectors in another Coordinate System (a new scaled/rotated/translated system) etc.
The origin of the Coordinate System of your Scene Node doesn't exist (actually exist, is the Identity Matrix, but you've didn't any transformation from the point that was created)

Matrices that I've used most so far:

Transform/Model/World Matrix (scale/rotate/translate my player)
View Matrix (put a Enemy to face the player given a eye position and a target position)
Projection (render something like a hologram)

Good Luck! I hope that you've understood a little (and my words too).

When you mean scale do you mean you are enlarging a 2D sprite or a 3D model to be of small or larger size than its normal size?

I understanding the rotate. You can change the angle of where the object is facing.

What I don't get is the translate. What do you mean by translate the player?

Well, I'm going to take a piece of code of my Software.

void Entity::Update(float dt)
{
position += velocity * dt;

transform = Matrix44(); //reset to identity

//scale
transform.m11 = scale.x;
transform.m22 =  scale.y;
transform.m33 = scale.z;

//rotate
transform = transform * rotation;

//translate
transform.m41 = position.x;
transform.m42 = position.y;
transform.m43 = position.z;
}
Note that you could do a Scale, Rotation, a Translation Matrix and multiply all together Transform = (S * R * T) because one will transform another in the sequence.
But to be fast, we can reset the matrix, set the scale, multiply by the rotation (the currently is the scale) and set the translation. Note that the Matrices are in Row Major Order.

If you want to understand the concepts you MUST write your own Algebra Library (Vector, Matrix).
After, you can play like a video-game. Put a camera position behind the player (multiplying a offset with the player's transform), make enemies face the player (View Matrix) or do orthographic projections like those clips that we see on Dead Space's cut scenes (Projection Matrix).
3D Rotations are very different from the 2Ds because there are 3 axis. In 2D with one angle you can describe the player's rotation. In 3D you'll need the Euler Angles. I don't recommend to extract a rotation matrices from those angles. Instead, keep doing rotation changing when it's needed it and later extract the angles.
With a decent knowledge of matrices you can do everything like: writing a Graphics/Physics Engine, Collision Methods, etc.

So WORTH a lot to studying that.

Is the collision method more advanced with matrices? Is it like pixel perfect collision very precise wise? I done a simple collision method in my 2D game but it involved checking a object type of a certain game object in a list and verifying valid intersection of overlapping rectangles.

Is the transform part of the code always the whole matrix of some worldspace or is it a matrix that contain's a certain object's data(position,velocity) ?

Yeah I can totally see it is worth studying for. A lot of interesting stuff.

Edited by warnexus, 19 December 2013 - 09:29 AM.

### #12Kaptein  Prime Members   -  Reputation: 1353

Like
0Likes
Like

Posted 19 December 2013 - 11:32 AM

Is the collision method more advanced with matrices? Is it like pixel perfect collision very precise wise? I done a simple collision method in my 2D game but it involved checking a object type of a certain game object in a list and verifying valid intersection of overlapping rectangles.

Is the transform part of the code always the whole matrix of some worldspace or is it a matrix that contain's a certain object's data(position,velocity) ?

Yeah I can totally see it is worth studying for. A lot of interesting stuff.

Collision can be solved any way you want.

You can for example transform from one coordinate system to another so that you are able to use rectangle test. Since a 4x3 or 4x4 matrix is enough to represent simple coordinate systems.

Linear algebra can however also be used for just about any type of collision detection, from distance tests to plane intersection.

Imagine you are rendering 500 particles, and you want to only render those who are atleast some measure of "directly in front of camera"

Let vector P = (particleX, Y, Z) and C  = (cameraX, Y, Z)

Then, the direction vector from camera to the particle is:

F = normalize(P - C)

And our look vector is:

L = (camera direction vector)

Programmatically L = ( sin(yrot) * cos(xrot), -sin(xrot), -cos(yrot) * cos(xrot) ), or simply stored as a quaternion or euler angle if you want to.

Now, using the dot product we can see get the cos(angle) of this direction, which tells us how much it faces that direction.

It will range from -1 to 1 (because its cos()), and -1 means the particle is behind the camera, while 1 means you are looking STRAIGHT at it (perfectly)

so, in code we can now do a test:

Let A be a positive number that reflects the limits of the minimum of the camera FOV (both X and Y axes).

if (F.dot(L) > A)

{

// render particle

}

### #13ApochPiQ  Moderators   -  Reputation: 11932

Like
2Likes
Like

Posted 19 December 2013 - 11:52 AM

A raytracer is a good project that will apply plenty of linear algebra concepts and test your problem solving abilities. It also is really cool to look at the results, so it's (IMO) a very fun project to work on.

Maker of Machinery

### #14warnexus  Prime Members   -  Reputation: 1172

Like
0Likes
Like

Posted 19 December 2013 - 06:13 PM

A raytracer is a good project that will apply plenty of linear algebra concepts and test your problem solving abilities. It also is really cool to look at the results, so it's (IMO) a very fun project to work on.

I will bear in mind about that. Can I do something like with any graphics rendering API like OpenGL? Sounds trivial but I need a confirmation of what other options I can also use.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS