# Perspective Projection

**URL:** <https://forum.kirupa.com/t/perspective-projection/277678>\
**Category:** flash\
**Created:** [December 15, 2008, 9:02pm UTC](https://forum.kirupa.com/t/perspective-projection/277678 "2008-12-15T21:02:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjonsson](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@mjonsson](https://forum.kirupa.com/u/mjonsson)\
**Post date:** [December 15, 2008, 9:02pm UTC](https://forum.kirupa.com/t/perspective-projection/277678/1 "2008-12-15T21:02:45Z")

</div>

I’m trying to get my head around some 3D graphics, but ran into trouble.

I have a number of points that make up a cube. Very simple.

I use an orthographic projection matrix to display it.

But when I try to apply a perspective projection matrix it looks like anything but a cube. I’ve tried multiple

ways to get it to work but it still doesn’t.

I have attached my source code.

By commenting an uncommenting the following lines (in 3DGraphics.as) you can switch between the orthographic projection and perspective projection matrix. As you can see when just using the orthographic projection matrix it works fine. But with the perspective it doesn’t.

// Ortographic and perspective  
// mP = mPers.multiplyMatrix(mOrto);

// Just ortographic  
mP = mOrto;

Any help on why my perspective matrix isn’t working is appreciated.

The perspective matrix looks like this. In a column major order:

n is the near plane and f the far plane.

mA[0] = n;  
mA[5] = n;  
mA[10] = n+f;  
mA[11] = 1;  
mA[14] = -(f\*n);  
mA[15] = 0;

Thanks!

/ Magnus
