Java Code Examples for javax.vecmath.Matrix4d#rotY()

The following examples show how to use javax.vecmath.Matrix4d#rotY() . 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: InstanceBodyWriterTools.java    From eplmp with Eclipse Public License 1.0 6 votes vote down vote up
static Matrix4d combineTransformation(Matrix4d matrix, Vector3d translation, Vector3d rotation) {
    Matrix4d gM = new Matrix4d(matrix);
    Matrix4d m = new Matrix4d();

    m.setIdentity();
    m.setTranslation(translation);
    gM.mul(m);

    m.setIdentity();
    m.rotZ(rotation.z);
    gM.mul(m);

    m.setIdentity();
    m.rotY(rotation.y);
    gM.mul(m);

    m.setIdentity();
    m.rotX(rotation.x);
    gM.mul(m);

    return gM;
}
 
Example 2
Source File: Robot_Phybot.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
public void setupModels(DHRobotEntity robot) {
	material = new MaterialEntity();
	float r=0.75f;
	float g=0.15f;
	float b=0.15f;
	material.setDiffuseColor(r,g,b,1);
	
	try {
		robot.links.get(0).setModelFilename("/Sixi/anchor.stl");
		robot.links.get(1).setModelFilename("/Sixi/shoulder.stl");
		robot.links.get(2).setModelFilename("/Sixi/bicep.stl");
		robot.links.get(3).setModelFilename("/Sixi/elbow.stl");
		robot.links.get(5).setModelFilename("/Sixi/forearm.stl");
		robot.links.get(6).setModelFilename("/Sixi/wrist.stl");
		robot.links.get(7).setModelFilename("/Sixi/hand.stl");

		for( DHLink link : robot.links ) link.setModelScale(0.1f);
		robot.links.get(1).getModel().adjustOrigin(new Vector3d(0, 0, -25));
		robot.links.get(2).getModel().adjustOrigin(new Vector3d(0, -5, -25));
		robot.links.get(2).getModel().adjustRotation(new Vector3d(-11.3,0,0));
		
		robot.links.get(5).getModel().adjustOrigin(new Vector3d(0, 0, -60));
		robot.links.get(6).getModel().adjustOrigin(new Vector3d(0, 0, -70));
		robot.links.get(7).getModel().adjustOrigin(new Vector3d(0, 0, -74));

		Matrix4d rot = new Matrix4d();
		Matrix4d rotX = new Matrix4d();
		Matrix4d rotY = new Matrix4d();
		Matrix4d rotZ = new Matrix4d();
		rot.setIdentity();
		rotX.rotX((float)Math.toRadians(90));
		rotY.rotY((float)Math.toRadians(0));
		rotZ.rotZ((float)Math.toRadians(0));
		rot.set(rotX);
		rot.mul(rotY);
		rot.mul(rotZ);
		Matrix4d pose = new Matrix4d(rot);
		Vector3d adjustPos = new Vector3d(0, 5, -50);
		pose.transform(adjustPos);
		
		robot.links.get(3).getModel().adjustOrigin(adjustPos);
		robot.links.get(3).getModel().adjustRotation(new Vector3d(90, 0, 0));
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 3
Source File: DragBallEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
protected void rollY(double angRadians) {
	// apply transform about the origin  change translation to rotate around something else.
	Matrix4d temp = new Matrix4d();
	temp.rotY(angRadians);
	rotationInternal(temp);
}
 
Example 4
Source File: TestUnitQuaternions.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Test {@link UnitQuaternions#orientationMetric(Point3d[], Point3d[])} on a
 * real structure, which will be deviating a little bit every time.
 *
 * @throws StructureException
 * @throws IOException
 */
@Test
public void testOrientationMetricIncrement() throws IOException,
		StructureException {

	// The rotation increment will be Pi/10, Pi/15 and Pi/12 degrees in X,Y
	// and Z
	Matrix4d transform = new Matrix4d();
	transform.rotX(Math.PI / 10);
	transform.rotY(Math.PI / 12);
	transform.rotZ(Math.PI / 15);

	// Get points from a structure.
	Structure pdb = StructureIO.getStructure("4hhb.A");
	Point3d[] cloud = Calc.atomsToPoints(StructureTools
			.getRepresentativeAtomArray(pdb));
	Point3d[] cloud2 = CalcPoint.clonePoint3dArray(cloud);

	// Center the clouds at the origin
	CalcPoint.center(cloud);
	CalcPoint.center(cloud2);

	// Their orientation is equal at this stage
	double m0 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertEquals(m0, 0.0, 0.001);

	// Assert it keeps incrementing every time transform is applied
	CalcPoint.transform(transform, cloud2);
	double m1 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m1 > m0);

	CalcPoint.transform(transform, cloud2);
	double m2 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m2 > m1);

	CalcPoint.transform(transform, cloud2);
	double m3 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m3 > m2);

	CalcPoint.transform(transform, cloud2);
	double m4 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m4 > m3);

	CalcPoint.transform(transform, cloud2);
	double m5 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m5 > m4);

	CalcPoint.transform(transform, cloud2);
	double m6 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m6 > m5);

	CalcPoint.transform(transform, cloud2);
	double m7 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m7 > m6);

	CalcPoint.transform(transform, cloud2);
	double m8 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m8 > m7);

	CalcPoint.transform(transform, cloud2);
	double m9 = UnitQuaternions.orientationMetric(cloud, cloud2);
	assertTrue(m9 > m8);
}