Java Code Examples for javax.vecmath.Matrix4d#setElement()
The following examples show how to use
javax.vecmath.Matrix4d#setElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleAlignmentXMLParser.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public static Matrix4d parseMatrix4d(Node node) { Matrix4d m = new Matrix4d(); NamedNodeMap atts = node.getAttributes(); for (int x=0; x<4; x++){ for (int y=0; y<4; y++){ String key = "mat"+(x+1)+(y+1); String value = atts.getNamedItem(key).getTextContent(); m.setElement(x, y, new Double(value)); } } return m; }
Example 2
Source File: CifFileConsumerImpl.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
private void setStructNcsOps() { List<Matrix4d> ncsOperators = new ArrayList<>(); for (int rowIndex = 0; rowIndex < structNcsOper.getRowCount(); rowIndex++) { if (!"generate".equals(structNcsOper.getCode().get(rowIndex))) { continue; } try { Matrix4d operator = new Matrix4d(); operator.setElement(0, 0, structNcsOper.getMatrix11().get(rowIndex)); operator.setElement(0, 1, structNcsOper.getMatrix12().get(rowIndex)); operator.setElement(0, 2, structNcsOper.getMatrix13().get(rowIndex)); operator.setElement(1, 0, structNcsOper.getMatrix21().get(rowIndex)); operator.setElement(1, 1, structNcsOper.getMatrix22().get(rowIndex)); operator.setElement(1, 2, structNcsOper.getMatrix23().get(rowIndex)); operator.setElement(2, 0, structNcsOper.getMatrix31().get(rowIndex)); operator.setElement(2, 1, structNcsOper.getMatrix32().get(rowIndex)); operator.setElement(2, 2, structNcsOper.getMatrix33().get(rowIndex)); operator.setElement(3, 0, 0); operator.setElement(3, 1, 0); operator.setElement(3, 2, 0); operator.setElement(3, 3, 1); ncsOperators.add(operator); } catch (NumberFormatException e) { logger.warn("Error parsing doubles in NCS operator list, skipping operator {}", rowIndex + 1); } } if (ncsOperators.size() > 0) { structure.getCrystallographicInfo() .setNcsOperators(ncsOperators.toArray(new Matrix4d[0])); } }
Example 3
Source File: RotationSolver.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
private void solve() { initialize(); int maxSymOps = subunits.getSubunitCount(); boolean isSpherical = isSpherical(); // for cases with icosahedral symmetry n cannot be higher than 60, should check for spherical symmetry here // isSpherical check added 08-04-11 if (maxSymOps % 60 == 0 && isSpherical) { maxSymOps = 60; } AxisAngle4d sphereAngle = new AxisAngle4d(); Matrix4d transformation = new Matrix4d(); int n = subunits.getSubunitCount(); int sphereCount = SphereSampler.getSphereCount(); List<Double> angles = getAngles(); for (int i = 0; i < sphereCount; i++) { // Sampled orientation //TODO The SphereSampler samples 4D orientation space. We really // only need to sample 3D unit vectors, since we use limited // angles. -SB SphereSampler.getAxisAngle(i, sphereAngle); // Each valid rotation angle for (double angle : angles) { // apply rotation sphereAngle.angle = angle; transformation.set(sphereAngle); // Make sure matrix element m33 is 1.0. It's not on Linux. transformation.setElement(3, 3, 1.0); for (int j = 0; j < n; j++) { transformedCoords[j].set(originalCoords[j]); transformation.transform(transformedCoords[j]); } // get permutation of subunits and check validity/uniqueness List<Integer> permutation = getPermutation(); // System.out.println("Rotation Solver: permutation: " + i + ": " + permutation); // check if novel if ( evaluatedPermutations.containsKey(permutation)) { continue; //either invalid or already added } Rotation newPermutation = isValidPermutation(permutation); if (newPermutation != null) { completeRotationGroup(newPermutation); } // check if all symmetry operations have been found. if (rotations.getOrder() >= maxSymOps) { return; } } } }
Example 4
Source File: SimpleMMcifConsumer.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
private void setStructNcsOps() { ArrayList<Matrix4d> ncsOperators = new ArrayList<Matrix4d>(); for (StructNcsOper sNcsOper:structNcsOper) { if (!sNcsOper.getCode().equals("generate")) continue; try { Matrix4d op = new Matrix4d(); op.setElement(3, 0, 0.0); op.setElement(3, 1, 0.0); op.setElement(3, 2, 0.0); op.setElement(3, 3, 1.0); op.setElement(0, 0, Double.parseDouble(sNcsOper.getMatrix11())); op.setElement(0, 1, Double.parseDouble(sNcsOper.getMatrix12())); op.setElement(0, 2, Double.parseDouble(sNcsOper.getMatrix13())); op.setElement(1, 0, Double.parseDouble(sNcsOper.getMatrix21())); op.setElement(1, 1, Double.parseDouble(sNcsOper.getMatrix22())); op.setElement(1, 2, Double.parseDouble(sNcsOper.getMatrix23())); op.setElement(2, 0, Double.parseDouble(sNcsOper.getMatrix31())); op.setElement(2, 1, Double.parseDouble(sNcsOper.getMatrix32())); op.setElement(2, 2, Double.parseDouble(sNcsOper.getMatrix33())); op.setElement(0, 3, Double.parseDouble(sNcsOper.getVector1())); op.setElement(1, 3, Double.parseDouble(sNcsOper.getVector2())); op.setElement(2, 3, Double.parseDouble(sNcsOper.getVector3())); ncsOperators.add(op); } catch (NumberFormatException e) { logger.warn("Error parsing doubles in NCS operator list, skipping operator {}", structNcsOper.indexOf(sNcsOper)+1); } } // we only set it if not empty, otherwise remains null if (ncsOperators.size()>0) { structure.getCrystallographicInfo().setNcsOperators( ncsOperators.toArray(new Matrix4d[ncsOperators.size()])); } }