Created
January 21, 2009 11:19
-
-
Save mariusz/49940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void NormalizeMesh() | |
| { | |
| double scaleX = 1.0; | |
| double scaleY = 1.0; | |
| if (this.sizeX > this.sizeY) | |
| { | |
| scaleY = this.sizeY / this.sizeX; | |
| } | |
| else if(this.sizeX < this.sizeY) | |
| { | |
| scaleX = this.sizeX / this.sizeY; | |
| } | |
| double maxXValue = this.mesh[0][this.mesh[0].Length - 1].X; | |
| double maxYValue = this.mesh[this.mesh.Length - 1][0].Y; | |
| double minXValue = this.mesh[0][0].X; | |
| double minYValue = this.mesh[0][0].Y; | |
| double maxZValue = this.mesh[0][0].Z; | |
| double minZValue = this.mesh[0][0].Z; | |
| for (int i = 0; i < this.mesh.Length; i++) | |
| { | |
| for (int j = 0; j < this.mesh[0].Length; j++) | |
| { | |
| if (this.mesh[i][j].Z > maxZValue) | |
| { | |
| maxZValue = this.mesh[i][j].Z; | |
| } | |
| if (this.mesh[i][j].Z < minZValue) | |
| { | |
| minZValue = this.mesh[i][j].Z; | |
| } | |
| } | |
| } | |
| this.ZvalueMax = maxZValue; | |
| this.ZValueMin = minZValue; | |
| CreateScale(); | |
| for (int i = 0; i < this.mesh.Length; i++) | |
| { | |
| for (int j = 0; j < this.mesh[0].Length; j++) | |
| { | |
| this.mesh[i][j].X = NormalizedValue(this.mesh[i][j].X, maxXValue, minXValue) * scaleX; | |
| this.mesh[i][j].Y = NormalizedValue(this.mesh[i][j].Y, maxYValue, minYValue) * scaleY; | |
| this.mesh[i][j].Z = NormalizedValue(this.mesh[i][j].Z, maxZValue, minZValue); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment