/** * Set the view matrix `s' is the scaling factor of translating real coordinates to the screen * coordinates (x0, y0) the screen coordinates of the center */ void setMatrix(Matrix3D viewMat, double s, double x0, double y0) { mat.unit(); mat.mult(viewMat); mat.scale(s, s, s); real2Screen = s; mat.translate(x0, y0, 0); transformed = false; }
public static Matrix3D Process(Matrix3D _cube, Definitions.Algorithm _algorithm) { Matrix3D res = new Matrix3D(); Set<Map.Entry<String, Matrix2D>> records = _cube.getIterator(); // Mean and standard deviation System.out.println("Processing Mean and SD"); Matrix2D _meanMat = RateOfMean.ColumnDepthMeanAndStandardDeviation(_cube, true, _algorithm); System.out.println("Processing layers..."); int c = 0; boolean print = false; boolean print2 = false; for (Map.Entry<String, Matrix2D> entry : records) { Matrix2D layer = entry.getValue(); MatrixDescriptor layerDesc = layer.getMatrixDescriptor(); Matrix2D layerSS = new Matrix2D(layerDesc); // Matrix2D layerSS = layer.DoGPUStandardScore(_meanMat); for (int col = 0; col < layerDesc.getNumCols(); col++) { String colName = layerDesc.getColumnAt(col); float _mean = _meanMat.GetElement(RateOfMean.Mean, layerDesc.getColumnAt(col)); float _sd = _meanMat.GetElement(RateOfMean.StandardDeviation, colName); for (int row = 0; row < layerDesc.getNumRows(); row++) { float _vv = layer.GetElement(row, col); if (_vv >= 8 && print == false) { print = true; float _ss = (layer.GetElement(row, col) - _mean) / _sd; System.out.println(_ss); } layerSS.SetElement( layerDesc.getRowAt(row), layerDesc.getColumnAt(col), (layer.GetElement(row, col) - _mean) / _sd); } } if (print == true && print2 == false) { print2 = true; layerSS.Debug(); } res.AddLayer(entry.getKey(), layerSS); System.out.println("Standard Score of matrix " + c + " of " + records.size()); c++; } return res; }
public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); tmpMatrix.unit(); tmpMatrix.xrot(360.0 * (mouseY - y) / getSize().height); tmpMatrix.yrot(360.0 * (x - mouseX) / getSize().width); viewMatrix.mult(tmpMatrix); repaint(); mouseX = x; mouseY = y; e.consume(); }
public static void Test3D() { MatrixDescriptor testDesc = new MatrixDescriptor(InfoType.USER, InfoType.ARTIFACT); testDesc.AddColDesc("circumf"); testDesc.AddColDesc("area_cy"); testDesc.AddColDesc("area_co"); testDesc.AddRowDesc("Alice"); testDesc.AddRowDesc("Carlos"); Matrix2D testMat = new Matrix2D(testDesc); testMat.SetElement("Alice", "circumf", 2); testMat.SetElement("Alice", "area_cy", 4); testMat.SetElement("Alice", "area_co", 6); testMat.SetElement("Carlos", "circumf", 6); testMat.SetElement("Carlos", "area_cy", 8); testMat.SetElement("Carlos", "area_co", 2); Matrix2D layer2 = new Matrix2D(testDesc); layer2.SetElement("Alice", "circumf", 7); layer2.SetElement("Alice", "area_cy", 4); layer2.SetElement("Alice", "area_co", 2); layer2.SetElement("Carlos", "circumf", 2); layer2.SetElement("Carlos", "area_cy", 9); layer2.SetElement("Carlos", "area_co", 4); Matrix3D _cube = new Matrix3D(); _cube.AddLayer(Database.CUBE_DEPTH_PREFIX + 0, testMat); _cube.AddLayer(Database.CUBE_DEPTH_PREFIX + 1, layer2); System.out.println(); System.out.println("z-score cube"); Matrix3D ssc = StandardScore.Process(_cube, Algorithm.CPU); ssc.Debug(); }
@Override public void draw(GLAutoDrawable glAutoDrawable, MatrixStack mvStack, Matrix3D pMat) { GL4 gl = (GL4) glAutoDrawable.getGL(); mvStack.pushMatrix(); // push translate translate(dxTranslate, dyTranslate, dzTranslate); mvStack.multMatrix(getTranslation()); mvStack.pushMatrix(); // push rotate rotate(dxRotate, dyRotate, dzRotate); mvStack.multMatrix(getRotation()); mvStack.multMatrix(getScale()); gl.glUniformMatrix4fv(IdentityLocs.getMvLoc(), 1, false, mvStack.peek().getFloatValues(), 0); gl.glUniformMatrix4fv(IdentityLocs.getProjLoc(), 1, false, pMat.getFloatValues(), 0); gl.glUniformMatrix4fv( IdentityLocs.getnlocation(), 1, false, (mvStack.peek().inverse().transpose().getFloatValues()), 0); // bind vertex values gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[index]); gl.glVertexAttribPointer(0, 3, GL.GL_FLOAT, false, 0, 0); gl.glEnableVertexAttribArray(0); // bind normal values gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[index + 2]); gl.glVertexAttribPointer(1, 3, GL.GL_FLOAT, false, 0, 0); gl.glEnableVertexAttribArray(1); // bind texture values gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vbo[index + 1]); gl.glVertexAttribPointer(2, 2, GL.GL_FLOAT, false, 0, 0); gl.glEnableVertexAttribArray(2); gl.glActiveTexture(gl.GL_TEXTURE0); gl.glBindTexture(gl.GL_TEXTURE_2D, texture); gl.glEnable(GL_CULL_FACE); gl.glFrontFace(GL_CCW); gl.glEnable(GL_DEPTH_TEST); gl.glDepthFunc(GL_LEQUAL); // draw arrays gl.glDrawArrays(GL_TRIANGLES, 0, myShape.getIndices().length); mvStack.popMatrix(); // pop rotate mvStack.popMatrix(); // pop translate }
/** Compute the Z-order */ void getZOrder() { // transform the coordinates if (!transformed) { mat.transform(realXYZ, screenXYZ, np); transformed = true; } // bubble sort z-order // zOrder[0] is the fartherest from the viewer // zOrder[np - 1] is the nearest to the viewer for (int i = 0; i < np; i++) zOrder[i] = i; for (int i = 0; i < np; i++) { // find the particle with the smallest z int jm = i, k; for (int j = i + 1; j < np; j++) if (screenXYZ[zOrder[j]][2] < screenXYZ[zOrder[jm]][2]) jm = j; if (jm != i) { k = zOrder[i]; zOrder[i] = zOrder[jm]; zOrder[jm] = k; } } }