# orthoOffCenter #5

Open
opened this Issue Feb 10, 2012 · 4 comments

Projects
None yet
2 participants

### RobDangerous commented Feb 10, 2012

 The orthoOffCenter matrices are either more clever than I can grasp or they are a little broken. They multiply y with zNear but not x - it should be either both or none. Also, they apply the x/y-translations in the addend which is multiplied with z, but for that to work correctly they should set w to z to cancel out the multplication with z. Changing those, the orthoOffCenterLH matrix looks like this: 2.0_zNear/(right-left), 0.0, 0.0, 0.0, 0.0, 2.0_zNear/(top-bottom), 0.0, 0.0, -1.0-2.0_left/(right-left), 1.0+2.0_top/(bottom-top), 1.0/(zFar-zNear), 1.0, 0.0, 0.0, zNear/(zNear-zFar), 0.0

### RobDangerous commented Feb 12, 2012

 The matrix I use now (which I think makes more sense, but is very different from the original): tx = -(right + left) / (right - left); ty = -(top + bottom) / (top - bottom); tz = -zNear / (zFar - zNear); 2.0 / (right - left), 0.0, 0.0, 0.0 0.0, 2.0 / (top - bottom), 0.0, 0.0 0.0, 0.0, 1.0 / (zFar - zNear), 0.0 tx, ty, tz, 1.0

### nshen commented Oct 14, 2014

 ``````public function orthoOffCenterLH(left:Number,right:Number, bottom:Number, top:Number, zNear:Number, zFar:Number):void { this.copyRawDataFrom(Vector.([ 2.0/(right-left), 0.0, 0.0, 0.0, 0.0, 2.0*/(top-bottom), 0.0, 0.0, 0.0, 0.0, 1.0/(zFar-zNear), 0.0, (left+right)/(left-right), (bottom+top)/(bottom-top), zNear/(zNear-zFar), 1.0 ])); } ``````

### nshen commented Oct 19, 2014

 right hand also have some problem. I think It should be like this. ``````public function orthoOffCenterRH(left:Number, right:Number,bottom:Number,top:Number,zNear:Number, zFar:Number):void { this.copyRawDataFrom(Vector.([ 2.0/(right-left), 0.0, 0.0, 0.0, 0.0, 2.0/(top-bottom), 0.0, 0.0, 0.0, 0.0, 1.0/(zNear-zFar), 0.0, (left+right)/(left-right), (bottom+top)/(bottom-top), zNear/(zNear-zFar), 1.0 ])); } ``````

### nshen commented Oct 19, 2014

 The row 3 and col 3 of orthoRH matrix should be 1.0/(zNear-zFar) ``````public function orthoRH(width:Number,height:Number,zNear:Number,zFar:Number):void { this.copyRawDataFrom(Vector.([ 2.0/width, 0.0, 0.0, 0.0, 0.0, 2.0/height, 0.0, 0.0, 0.0, 0.0, 1.0/(zNear-zFar), 0.0, 0.0, 0.0, zNear/(zNear-zFar), 1.0 ])); } ``````