当前位置: 首页>>代码示例>>Java>>正文


Java Matrix4d.set方法代码示例

本文整理汇总了Java中javax.vecmath.Matrix4d.set方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4d.set方法的具体用法?Java Matrix4d.set怎么用?Java Matrix4d.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.vecmath.Matrix4d的用法示例。


在下文中一共展示了Matrix4d.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AffineTransform3D

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public AffineTransform3D(double[] coeficients) {
    matrix = new Matrix4d();  	
    if (coeficients.length==9) {
        matrix.set(new Matrix3d(coeficients));
    } else if (coeficients.length==12) {
        double[] extendedCoeficients = new double[16];
        for (int i=0; i<coeficients.length; ++i) {
            extendedCoeficients[i] = coeficients[i];
        }
        extendedCoeficients[12] = 0;
        extendedCoeficients[13] = 0;
        extendedCoeficients[14] = 0;
        extendedCoeficients[15] = 1;
        matrix.set(extendedCoeficients);
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:17,代码来源:AffineTransform3D.java

示例2: getViewTransform

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
 * Get the mapping from view to world coordinates
 * @param trans
 */
public void getViewTransform( Matrix4d matrix, double angle )
{
    Point3d eyePoint = new Point3d( mLookAtPoint );
    Vector3d dir = new Vector3d( mLookDirection );
    if ( angle != 0d ) {
        double[] rotMat = new double[16];
        AxisAngle4d rotAA = new AxisAngle4d( mUpDirection, angle );
        set( rotAA, rotMat );
        transform( rotMat, dir );
    }
    dir .scale( -mDistance );
    eyePoint .add( dir );
    
    double[] mat = new double[16];
    lookAt( mat, eyePoint, mLookAtPoint, mUpDirection );
    matrix .set( mat );
}
 
开发者ID:vZome,项目名称:vzome-core,代码行数:22,代码来源:Camera.java

示例3: createRotationOx

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static AffineTransform3D createRotationOx(double theta) {
    Matrix3d matrix3d = new Matrix3d();
    matrix3d.rotX(theta);
    Matrix4d matrix4d = new Matrix4d();
    matrix4d.set(matrix3d);
    return new AffineTransform3D(matrix4d);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:AffineTransform3D.java

示例4: createRotationOy

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static AffineTransform3D createRotationOy(double theta) {
    Matrix3d matrix3d = new Matrix3d();
    matrix3d.rotY(theta);
    Matrix4d matrix4d = new Matrix4d();
    matrix4d.set(matrix3d);
    return new AffineTransform3D(matrix4d);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:AffineTransform3D.java

示例5: createRotationOz

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static AffineTransform3D createRotationOz(double theta) {
    Matrix3d matrix3d = new Matrix3d();
    matrix3d.rotZ(theta);
    Matrix4d matrix4d = new Matrix4d();
    matrix4d.set(matrix3d);
    return new AffineTransform3D(matrix4d);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:AffineTransform3D.java

示例6: trackballRolled

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private  void trackballRolled( MouseEvent e )
  {
      // get the new coordinates
      int newX = e .getX();
      int newY = e .getY();
      // the angle in degrees is just the pixel differences
      int angleX = newX - oldX;
      int angleY = newY - oldY;
      // set the old values
      oldX = newX;
      oldY = newY;

      double radians = ((double) angleY) * mSpeed;
      AxisAngle4d yAngle = new AxisAngle4d( new Vector3d( 1d, 0d, 0d ), radians );

      radians = ((double) angleX) * mSpeed;
      AxisAngle4d xAngle = new AxisAngle4d( new Vector3d( 0d, 1d, 0d ), radians );

Matrix4d x = new Matrix4d();
      x.set( xAngle );
Matrix4d y = new Matrix4d();
      y.set( yAngle );
      x .mul( y );
      Quat4d q = new Quat4d();
      x .get( q );

      trackballRolled( q );
  }
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:29,代码来源:Trackball.java

示例7: setViewTransformation

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
@Override
public void setViewTransformation( Matrix4d trans, int eye )
{
	if ( eye == Viewer .MONOCULAR ) {
		Matrix3d justRotation3d = new Matrix3d();
		trans .get( justRotation3d );
		justRotation3d .invert(); // to match the invert() in the caller
		Matrix4d finalTransform = new Matrix4d();
		finalTransform .set( this .translation );
		finalTransform .setRotation( justRotation3d );
		finalTransform .invert(); // to match the invert() in the caller
		this .delegate .setViewTransformation( finalTransform, Viewer .MONOCULAR );
	}
}
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:15,代码来源:TrackballRenderingViewer.java

示例8: trackballRolled

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void trackballRolled( Quat4d roll )
{
    mViewPlatform .getWorldRotation( roll );
    Matrix4d rollM = new Matrix4d();
    rollM.set( roll );
    // roll is now a rotation in world coordinates
    rollM.transform( zoneVector3d );
    mapVectorToAxis();
}
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:10,代码来源:ZoneVectorBall.java

示例9: solve

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private void solve() {
		initialize();
		Vector3d trans = new Vector3d(subunits.getCentroid());
		trans.negate();
		List<Point3d[]> traces = subunits.getTraces();

//		Point3d[] x = SuperPosition.clonePoint3dArray(traces.get(0));
//		SuperPosition.center(x);
//		Point3d[] y = SuperPosition.clonePoint3dArray(traces.get(1));
//		SuperPosition.center(y);

		Point3d[] x = CalcPoint.clonePoint3dArray(traces.get(0));
		CalcPoint.translate(trans, x);
		Point3d[] y = CalcPoint.clonePoint3dArray(traces.get(1));
		CalcPoint.translate(trans, y);

		// TODO implement this piece of code using at origin superposition
		Quat4d quat = UnitQuaternions.relativeOrientation(
				x, y);
		AxisAngle4d axisAngle = new AxisAngle4d();
		Matrix4d transformation = new Matrix4d();
		
		transformation.set(quat);
		axisAngle.set(quat);
		
		Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
		if (axis.lengthSquared() < 1.0E-6) {
			axisAngle.x = 0;
			axisAngle.y = 0;
			axisAngle.z = 1;
			axisAngle.angle = 0;
		} else {
			axis.normalize();
			axisAngle.x = axis.x;
			axisAngle.y = axis.y;
			axisAngle.z = axis.z;
		}
		
		CalcPoint.transform(transformation, y);

		// if rmsd or angle deviation is above threshold, stop
		double angleThresholdRadians = Math.toRadians(parameters.getAngleThreshold());
		double deltaAngle = Math.abs(Math.PI-axisAngle.angle);

		if (deltaAngle > angleThresholdRadians) {
			rotations.setC1(subunits.getSubunitCount());
			return;
		}

		// add unit operation
		addEOperation();

		// add C2 operation
		int fold = 2;
		combineWithTranslation(transformation);
		List<Integer> permutation = Arrays.asList(1,0);
		QuatSymmetryScores scores = QuatSuperpositionScorer.calcScores(subunits, transformation, permutation);
		scores.setRmsdCenters(0.0); // rmsd for superposition of two subunits centers is zero by definition

		if (scores.getRmsd() > parameters.getRmsdThreshold() || deltaAngle > angleThresholdRadians) {
			rotations.setC1(subunits.getSubunitCount());
			return;
		}

		Rotation symmetryOperation = createSymmetryOperation(permutation, transformation, axisAngle, fold, scores);
		rotations.addRotation(symmetryOperation);
	}
 
开发者ID:biojava,项目名称:biojava,代码行数:68,代码来源:C2RotationSolver.java

示例10: testRelativeOrientation

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
 * Test {@link UnitQuaternions#relativeOrientation(Point3d[], Point3d[])} on
 * a real structure. Test recovering of the angle applied.
 * 
 * @throws StructureException
 * @throws IOException
 */
@Test
public void testRelativeOrientation() throws IOException,
		StructureException {

	// Get points from a structure.
	Structure pdb = StructureIO.getStructure("4hhb.A");
	Point3d[] cloud = Calc.atomsToPoints(StructureTools
			.getRepresentativeAtomArray(pdb));
	Point3d[] cloud2 = CalcPoint.clonePoint3dArray(cloud);
	
	// Test orientation angle equal to 0 at this point
	double angle = UnitQuaternions.orientationAngle(cloud, cloud2, false);
	assertEquals(angle, 0, 0.001);
	
	// Apply a 30 degree rotation to cloud
	AxisAngle4d axis = new AxisAngle4d(new Vector3d(1,1,1), Math.PI / 6);
	Matrix4d transform = new Matrix4d();
	transform.set(axis);
	
	CalcPoint.transform(transform, cloud);
	angle = UnitQuaternions.orientationAngle(cloud, cloud2, false);
	angle = Math.min(Math.abs(2 * Math.PI - angle), angle);
	
	// Test that angle was recovered
	assertEquals(angle, Math.PI / 6, 0.001);
}
 
开发者ID:biojava,项目名称:biojava,代码行数:34,代码来源:TestUnitQuaternions.java

示例11: postSet

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void postSet() {
  final Matrix4d m = getM();
  if (translation != null) {
    final Matrix4d t = new Matrix4d();
    t.set(translation);
    m.mul(t);
  }
  if (rotation != null) {
    final Matrix4d r = new Matrix4d();
    r.rotX(Math.toRadians(rotation.x));
    m.mul(r);
    r.rotY(Math.toRadians(rotation.y));
    m.mul(r);
    r.rotZ(Math.toRadians(rotation.z));
    m.mul(r);
  }
  if (scale != null) {
    final Matrix4d s = new Matrix4d();
    s.setIdentity();
    s.setElement(0, 0, scale.x);
    s.setElement(1, 1, scale.y);
    s.setElement(2, 2, scale.z);
    m.mul(s);
  }
  final Matrix4d minv = getMinv();
  minv.invert(getM());
}
 
开发者ID:billohreally,项目名称:ray-tracer,代码行数:28,代码来源:TransformXml.java

示例12: push

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void push() {
    Matrix4d mat = this.getMatrix();
    mat.set(this.matrixStack.peek());
    this.matrixStack.push(mat);
}
 
开发者ID:gegy1000,项目名称:BlockSystems,代码行数:6,代码来源:Matrix.java

示例13: evaluatePermutation

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private boolean evaluatePermutation(List<Integer> permutation) {
	// permutate subunits
	for (int j = 0, n = subunits.getSubunitCount(); j < n; j++) {
		transformedCoords[j].set(originalCoords[permutation.get(j)]);
	}

	int fold = PermutationGroup.getOrder(permutation);
	
	// TODO implement this piece of code using at origin superposition
	Quat4d quat = UnitQuaternions.relativeOrientation(
			originalCoords, transformedCoords);
	AxisAngle4d axisAngle = new AxisAngle4d();
	Matrix4d transformation = new Matrix4d();
	
	transformation.set(quat);
	axisAngle.set(quat);
	
	Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
	if (axis.lengthSquared() < 1.0E-6) {
		axisAngle.x = 0;
		axisAngle.y = 0;
		axisAngle.z = 1;
		axisAngle.angle = 0;
	} else {
		axis.normalize();
		axisAngle.x = axis.x;
		axisAngle.y = axis.y;
		axisAngle.z = axis.z;
	}
	
	CalcPoint.transform(transformation, transformedCoords);
	
	double subunitRmsd = CalcPoint.rmsd(transformedCoords, originalCoords);

	if (subunitRmsd <parameters.getRmsdThreshold()) {
		// transform to original coordinate system
		combineWithTranslation(transformation);
		QuatSymmetryScores scores = QuatSuperpositionScorer.calcScores(subunits, transformation, permutation);
		if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
			return false;
		}

		scores.setRmsdCenters(subunitRmsd);
		Rotation symmetryOperation = createSymmetryOperation(permutation, transformation, axisAngle, fold, scores);
		rotations.addRotation(symmetryOperation);
		return true;
	}
	return false;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:50,代码来源:SystematicSolver.java

示例14: solve

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
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;
			}
		}
	}
}
 
开发者ID:biojava,项目名称:biojava,代码行数:63,代码来源:RotationSolver.java

示例15: superimposePermutation

import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
 * Superimpose subunits based on the given permutation. Then check whether
 * the superposition passes RMSD thresholds and create a Rotation to
 * represent it if so.
 * @param permutation A list specifying which subunits should be aligned by the current transformation
 * @return A Rotation representing the permutation, or null if the superposition did not meet thresholds.
 */
private Rotation superimposePermutation(List<Integer> permutation) {
	// permutate subunits
	for (int j = 0, n = subunits.getSubunitCount(); j < n; j++) {
		transformedCoords[j].set(originalCoords[permutation.get(j)]);
	}

	int fold = PermutationGroup.getOrder(permutation);

	// get optimal transformation and axisangle by subunit superposition
	// TODO implement this piece of code using at origin superposition
	Quat4d quat = UnitQuaternions.relativeOrientation(
			originalCoords, transformedCoords);
	AxisAngle4d axisAngle = new AxisAngle4d();
	Matrix4d transformation = new Matrix4d();
	
	transformation.set(quat);
	axisAngle.set(quat);
	
	Vector3d axis = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
	if (axis.lengthSquared() < 1.0E-6) {
		axisAngle.x = 0;
		axisAngle.y = 0;
		axisAngle.z = 1;
		axisAngle.angle = 0;
	} else {
		axis.normalize();
		axisAngle.x = axis.x;
		axisAngle.y = axis.y;
		axisAngle.z = axis.z;
	}
	
	CalcPoint.transform(transformation, transformedCoords);
	double subunitRmsd = CalcPoint.rmsd(transformedCoords, originalCoords);

	if (subunitRmsd < parameters.getRmsdThreshold()) {
		combineWithTranslation(transformation);

		// evaluate superposition of CA traces
		QuatSymmetryScores scores = QuatSuperpositionScorer.calcScores(subunits, transformation, permutation);
		if (scores.getRmsd() < 0.0 || scores.getRmsd() > parameters.getRmsdThreshold()) {
			return null;
		}

		scores.setRmsdCenters(subunitRmsd);
		Rotation symmetryOperation = createSymmetryOperation(permutation, transformation, axisAngle, fold, scores);
		return symmetryOperation;
	}
	return null;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:57,代码来源:RotationSolver.java


注:本文中的javax.vecmath.Matrix4d.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。