I have a Quad inside a Sprite3D:

const w:uint = 200, h:uint = 100; var quad:Quad = new Quad(w,h,0xff0000); var sprite3D:Sprite3D = new Sprite3D(); sprite3D.addChild(quad);

The vertices of that Quad are held in a vector of Vector3Ds. I also have another empty vector to hold their transformed values:

const originalVertsV:Vector.<Vector3D> = new <Vector3D>[ new Vector3D(0,0,0), new Vector3D(w,0,0), new Vector3D(0,h,0), new Vector3D(w,h,0) ]; var transformedVertsV:Vector.<Vector3D> = new <Vector3D>[];

Now I'm going to rotate the sprite3D by -90 degrees along its x-axis and get the new coordinates of the vertices:

sprite3D.rotationX = deg2rad(-90); var matrix3D:Matrix3D = new Matrix3D(); sprite3D.getTransformationMatrix3D(this,matrix3D); var l:uint = originalVertsV.length; for (var i:uint=0; i<l; i++) { transformedVertsV[i] = matrix3D.transformVector(originalVertsV[i]); } trace(originalVertsV); //Vector3D(0, 0, 0), Vector3D(200, 0, 0), //Vector3D(0, 100, 0), Vector3D(200, 100, 0) trace(transformedVertsV); //Vector3D(0, 0, 0), Vector3D(200, 0, 0), //Vector3D(0, 0, -100), Vector3D(200, 0, -100)

The transformed coordinates are correct, but don't take into account the perspective projection. I'm trying to get the coordinates to match up exactly with the vertices as they are displayed on the screen. In this case, the coordinates would suggest the Quad is invisible because you're looking at its edge, but if the Quad is placed anywhere above or below the projection center, you can see it because of the perspective projection. How would I go about applying the perspective projection to my vector of coordinates?

I tried calculating the projected coordinates by hand according to this formula, but the results don't match up with the Quad on screen:

x = ((x - projectionCenter.x) / (z/focalLength)) + projectionCenter.x

y = ((y - projectionCenter.y) / (z/focalLength)) + projectionCenter.y