Sign in to follow this  
Nicholas Kong

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

Recommended Posts

Nicholas Kong    1535

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

Share this post


Link to post
Share on other sites
EarthBanana    1794

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

Share this post


Link to post
Share on other sites
Irlan    4067
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.
Your Scene Node is made with a lot of vertices.
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).

Share this post


Link to post
Share on other sites
Nicholas Kong    1535

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.

Share this post


Link to post
Share on other sites
Nicholas Kong    1535

 

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.
Your Scene Node is made with a lot of vertices.
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

Share this post


Link to post
Share on other sites
Key_46    540

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.

Share this post


Link to post
Share on other sites
arka80    1959


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

Share this post


Link to post
Share on other sites
Irlan    4067

 

 

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.
Your Scene Node is made with a lot of vertices.
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.

Share this post


Link to post
Share on other sites
Kaptein    2224

 

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% :D

Share this post


Link to post
Share on other sites
Nicholas Kong    1535

 



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!

Share this post


Link to post
Share on other sites
Nicholas Kong    1535

 

 

 

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.
Your Scene Node is made with a lot of vertices.
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

Share this post


Link to post
Share on other sites
Kaptein    2224

 

 

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

}

Share this post


Link to post
Share on other sites
ApochPiQ    23005

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.

Share this post


Link to post
Share on other sites
Nicholas Kong    1535

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this