I want to graphically display eigen-vectors and eigen-values of a matrix

I have begined with this relatively basic 3x3 matrix given at https://www.youtube.com/watch?v=C5uDVyKruFg&t=82

-1 2 2

2 2 -1

2 -1 2

Eigen-values of this matrix are 3 and -3

Eigen vectors of this matrix are

E3 = { 1/2 , 1 , 0 } and { 1/2 , 0 , 1 }

E-3 = { -2 , 1, 1 }

I have used the 3x3 matrix as three 3D coordinates for to display it as a triangle :

(since this is a symetric matrix, no need to handle the row or column major order)

x0 y0 z0

x1 y1 z1

x2 y2 z2

where (x0,y0,z0), (x1,y1,z1) and (x2,y2,z2) are 3D coordinates of the triangle vertices

After I have displayed eigen-vectors as 3D vectors for to try to understand what they really represent in 3D

(for this, I display each eigen-vector as a line in a different color)

But I don't graphically see what is the rapport between the triangle and his eigen-vectors :(

(the only think that I clearly see is that eigen-vectors are orthogonals but this is all)

Here is the basic code that I actually use for to display the triangle and his eigen-vectors

Code :

#include <GL/gl.h>
#include <GL/glut.h>
float angle = 0.0f;
float angleInc = 1;
GLfloat vertices[3][3];
void SetVertice( int idx, GLfloat x, GLfloat y, GLfloat z)
{
vertices[idx][0] = x;
vertices[idx][1] = y;
vertices[idx][2] = z;
}
void MakeArrays()
{
SetVertice(0, -1, 2, 2);
SetVertice(1, 2, 2, -1);
SetVertice(2, 2, -1, 2);
}
void DrawAxes()
{
glBegin(GL_LINES);
glColor3f( 1.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 1.0f, 0.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f( 0.0f, 0.0f, 1.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 1.0f);
glEnd();
}
void DrawHeigenVectors()
{
glBegin(GL_LINES);
glColor3f( 1.0f, 0.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 0.5f, 1.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( 0.5f, 0.0f, 1.0f);
glColor3f( 0.0f, 0.0f, 1.0f);
glVertex3f( 0.0f, 0.0f, 0.0f);
glVertex3f( -2.0f, 1.0f, 1.0f);
glEnd();
}
void DrawTriangle()
{
int i;
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
for( i = 0 ; i < 3 ; i++)
{
glVertex3fv(vertices[i]);
}
glEnd();
}
void renderScene(void)
{
// Clear Color and Depth Buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reset transformations
glLoadIdentity();
// Set the camera
gluLookAt( 0.0f, 0.0f, 10.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
glRotatef(angle, 1.0f, 1.0f, 1.0f);
// DrawAxes();
DrawTriangle();
DrawHeigenVectors();
angle += angleInc;
glutSwapBuffers();
}
void changeSize(int w, int h)
{
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if (h == 0)
h = 1;
float ratio = w * 1.0 / h;
// Use the Projection Matrix
glMatrixMode(GL_PROJECTION);
// Reset Matrix
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, w, h);
// Set the correct perspective.
gluPerspective(45.0f, ratio, 0.1f, 100.0f);
// Get Back to the Modelview
glMatrixMode(GL_MODELVIEW);
}
void keyboardFunc( unsigned char key, int x, int y )
{
switch ( key )
{
case 27: // Escape key
exit (0);
break;
case ' ' : // pause/play key
if( angleInc == 0.0f )
{
angleInc = 1.0f;
}
else
{
angleInc = 0.0f;
}
break;
}
glutPostRedisplay();
}
int main(int argc, char **argv)
{
// init GLUT and create window
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(640,480);
glutCreateWindow("Lighthouse3D- GLUT Tutorial");
// register callbacks
glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glutKeyboardFunc(keyboardFunc);
MakeArrays();
// here is the idle func registration
glutIdleFunc(renderScene);
// enter GLUT event processing cycle
glutMainLoop();
return 0;
}

I plane after to use eigen-values and eigen-vectors for to can handle the spectral compression of a 3D object via his Laplacian matrix

For example, for the very basic example of a triangle :

The Adjency matrix is :

0 1 1

1 0 1

1 1 0

The Degree matrix is :

2 0 0

0 2 0

0 0 2

So, the symetric Laplacian matrix Ls = D - A

2-1 -1

-1 2 -1

-1 -1 2

And the "true" Laplacian matrix is

(this seem the same but divided by 2)

1 -1/2 -1/2

-1/2 1 -1/2

-1/2 -1/2 1

But since I don't see the rapport between the 3D coordinates of a triangle and his eigen-vector,

it's again more difficult to imagine what is the rapport between a Laplacian matrix and his eigen-vectors :(

=> someone can help me a little to understand in more depth how I can represent eigen-values and eigen-vectors on a OpenGL 3D fashion , please ? ]]>

Ques: are "vectors" in glut/openGL

Also why would I want to use a polar system over s cartesian? ]]>

I'm a student from China, I met a interesting way to implement fisheye control. As the image shows, the left-top marked area matched right-top projection area.

I have try to implement this, but failed. I calculate the equation of minor arc, but the result can't match perfect. Am I right for doing this by calculate minor arc as boundary ? Or is there any API I can detect the projection area from origin image?

Thanks a lot!

i'm using glm for all the math, and i represent objects in "transform" objects:

Code :

struct Transformation
{
glm::vec3 Position;
glm::quat Rotation;
glm::mat4 Matrix() const { return glm::translate(Position) * glm::toMat4(Rotation); }
glm::mat4 View() const { return glm::inverse(Matrix()); }
};

from OpenAL (sound API), i get 2 directions for the "listener" (which is essentially the camera): forward and up dirction. the way i'm getting the "Transformation" is:

Code :

glm::quat al::listener::Orientation()
{
ALfloat orientation[6] = { 0 };
alGetListenerfv(AL_ORIENTATION, orientation);
/* get directions */
glm::vec3 forward(orientation[0], orientation[1], orientation[2]);
glm::vec3 up(orientation[3], orientation[4], orientation[5]);
/* get view matrix */
glm::mat4 view = glm::lookAt(glm::vec3(0, 0, 0), forward, up);
/* invert view matrix */
glm::mat4 transform = glm::inverse(view);
/* return rotation */
return glm::toQuat(transform);
}

i'm getting around the problem using matrices, but is there an easier / faster way to get the rotation somehow ??

thanks for any advice !! ]]>