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


Java Matrix3d.rotZ方法代码示例

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


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

示例1: addRotAroundAxis

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public static PointD addRotAroundAxis(double x, double y, double z, double axis) {

        // May be faster to rewrite with your own to reduce the number of calculations

        Matrix3d rotationMatrix = new Matrix3d();
        rotationMatrix.rotZ(z); // Add z rotation
        Matrix3d yRot = new Matrix3d();
        yRot.rotY(y);
        Matrix3d xRot = new Matrix3d();
        xRot.rotX(x);

        Matrix3d axisRot = new Matrix3d();
        axisRot.rotY(axis);

        rotationMatrix.mul(yRot);
        rotationMatrix.mul(xRot);
        rotationMatrix.mul(axisRot);

        return new PointD(Math.atan2(rotationMatrix.m21, rotationMatrix.m22),
                Math.atan2(-rotationMatrix.m20,Math.sqrt(rotationMatrix.m21 * rotationMatrix.m21 + rotationMatrix.m22 * rotationMatrix.m22)),
                Math.atan2(rotationMatrix.m10, rotationMatrix.m00));
    }
 
开发者ID:sekwah41,项目名称:SekC-Physics,代码行数:23,代码来源:MatrixMaths.java

示例2: paintSphericalVanishingPoints

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public void paintSphericalVanishingPoints(Graphics g) {
    final double EPS = 0.1;
    final int R = 1;
    g.setColor(Constants.Vanish_Color);
    Matrix3d RZ = new Matrix3d();
    Matrix3d RY = new Matrix3d();
    for (double rz = 0; rz < 2 * Math.PI; rz += EPS) {
        RZ.rotZ(rz);
        for (double ry = -Math.PI / 2; ry < Math.PI / 2; ry += EPS) {
            RY.rotY(ry);
            Vector3d v = new Vector3d(1, 0, 0);
            RY.transform(v);
            RZ.transform(v);
            Point2d vp = projection.vanishingPoint(v);
            if (vp != null) {
                g.fillOval((int) vp.x - R, (int) vp.y - R, 2 * R, 2 * R);
            }
        }
    }
}
 
开发者ID:sdghrmz,项目名称:jvircam,代码行数:21,代码来源:Painter.java

示例3: Rotation

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Creates a new instance of Translation.
 * 
 * @param center
 * @param xAngle
 * @param yAngle
 * @param zAngle
 */
public Rotation(Point3d center, double xAngle, double yAngle, double zAngle) {
	super();
	centerOfRotation = center;
	double x = Math.toRadians(xAngle);
	double y = Math.toRadians(yAngle);
	double z = Math.toRadians(zAngle);
	Matrix3d xrot = new Matrix3d();
	xrot.rotX(x);
	Matrix3d yrot = new Matrix3d();
	yrot.rotY(y);
	Matrix3d zrot = new Matrix3d();
	zrot.rotZ(z);
	yrot.mul(zrot);
	xrot.mul(yrot);
	rotation = xrot;
	toOrigin = new Translation(-centerOfRotation.x, -centerOfRotation.y,
			-centerOfRotation.z);
	toCenter = new Translation(centerOfRotation.x, centerOfRotation.y,
			centerOfRotation.z);
}
 
开发者ID:guiguito,项目名称:SiJaRayCluster,代码行数:29,代码来源:Rotation.java

示例4: getViewMatrix

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public Matrix3d getViewMatrix(int index) {
	Matrix3d m = new Matrix3d();
	switch (index) {
	case 0:
		m.setIdentity(); // front vertex-centered
		break;
	case 1:
		m.rotX(-0.6523581397843639); // back face-centered -0.5535743588970415 m.rotX(Math.toRadians(-26));
		break;
	case 2:
		m.rotZ(Math.PI/2);
		Matrix3d m1 = new Matrix3d();
		m1.rotX(-1.0172219678978445);
		m.mul(m1);
		break;
	default:
		throw new IllegalArgumentException("getViewMatrix: index out of range:" + index);
	}
	return m;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:22,代码来源:Icosahedron.java

示例5: getVertices

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Returns the vertices of an n-fold polygon of given radius and center
 * @return
 */
@Override
public Point3d[] getVertices() {
	Point3d[] polygon = new Point3d[2*n];
	Matrix3d m = new Matrix3d();

	Point3d center = new Point3d(0, 0, height/2);

	for (int i = 0; i < n; i++) {
		polygon[i] = new Point3d(0, circumscribedRadius, 0);
		m.rotZ(i*2*Math.PI/n);
		m.transform(polygon[i]);
		polygon[n+i] = new  Point3d(polygon[i]);
		polygon[i].sub(center);
		polygon[n+i].add(center);
	}

	return polygon;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:23,代码来源:Prism.java

示例6: getViewMatrix

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public Matrix3d getViewMatrix(int index) {
	Matrix3d m = new Matrix3d();
	switch (index) {
	case 0:
		m.setIdentity(); // C4 vertex-centered
		break;
	case 1:
		m.rotX(-0.5 * TETRAHEDRAL_ANGLE); // C3 face-centered  2.0*Math.PI/3
		Matrix3d m1 = new Matrix3d();
		m1.rotZ(Math.PI/4);
		m.mul(m1);
		break;
	case 2:
		m.rotY(Math.PI/4); // side face-centered
		break;
	default:
		throw new IllegalArgumentException("getViewMatrix: index out of range:" + index);
	}
	return m;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:22,代码来源:Octahedron.java

示例7: Quadcopter

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Generic quadcopter constructor.
 *
 * @param world          world where to place the vehicle
 * @param modelName      filename of model to load, in .obj format
 * @param orientation    "x" or "+"
 * @param armLength      length of arm from center
 * @param rotorThrust    full thrust of one rotor
 * @param rotorTorque    torque at full thrust of one rotor
 * @param rotorTimeConst spin-up time of rotor
 * @param rotorsOffset   rotors positions offset from gravity center
 * @throws FileNotFoundException if .obj model file not found
 */
public Quadcopter(World world, String modelName, String orientation, double armLength, double rotorThrust,
                  double rotorTorque, double rotorTimeConst, Vector3d rotorsOffset) throws FileNotFoundException {
    super(world, modelName);
    rotorPositions[0] = new Vector3d(0.0, armLength, 0.0);
    rotorPositions[1] = new Vector3d(0.0, -armLength, 0.0);
    rotorPositions[2] = new Vector3d(armLength, 0.0, 0.0);
    rotorPositions[3] = new Vector3d(-armLength, 0.0, 0.0);
    if (orientation.equals("x") || orientation.equals("X")) {
        Matrix3d r = new Matrix3d();
        r.rotZ(-Math.PI / 4);
        for (int i = 0; i < rotorsNum; i++) {
            r.transform(rotorPositions[i]);
        }
    } else if (orientation.equals("+")) {
    } else {
        throw new RuntimeException("Unknown orientation: " + orientation);
    }
    for (int i = 0; i < rotors.length; i++) {
        rotorPositions[i].add(rotorsOffset);
        Rotor rotor = rotors[i];
        rotor.setFullThrust(rotorThrust);
        rotor.setFullTorque(i < 2 ? -rotorTorque : rotorTorque);
        rotor.setTimeConstant(rotorTimeConst);
    }
}
 
开发者ID:DrTon,项目名称:jMAVSim,代码行数:39,代码来源:Quadcopter.java

示例8: createRotationOz

import javax.vecmath.Matrix3d; //导入方法依赖的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

示例9: paintComponent

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g); //To change body of generated methods, choose Tools | Templates.
    Point o = this.getWorldCenter();
    // z axis
    g.setColor(Constants.ZAxis_Color);
    g.drawLine(o.x, o.y, o.x, 0);

    g.setColor(Constants.Origin_Color);
    g.drawOval(o.x - Constants.Origin_Radius, o.y - Constants.Origin_Radius, 2 * Constants.Origin_Radius, 2 * Constants.Origin_Radius);

    if (camera != null) {
        Point c = this.getCameraLocation();
        g.setColor(Constants.Camera_Color);
        g.drawOval(c.x - Constants.Camera_Radius, c.y - Constants.Camera_Radius, 2 * Constants.Camera_Radius, 2 * Constants.Camera_Radius);

        double vfv = camera.getVerticalFieldOfView() / 2;
        double tilt = camera.getTiltAngle();
        boolean inFront = isInFrontOfCamera(Math.atan2(-camera.getPosition().y, -camera.getPosition().x));
        if (!inFront) {
            tilt = Math.PI - tilt;
        }
        Point3d p1 = new Point3d(this.getWidth(), 0, 0);
        Point3d p2 = new Point3d(this.getWidth(), 0, 0);
        Matrix3d rot = new Matrix3d();
        rot.rotZ(tilt + vfv);
        rot.transform(p1);
        rot.rotZ(tilt - vfv);
        rot.transform(p2);
        g.setColor(Constants.FOV_Color);
        g.drawLine(c.x, c.y, c.x + (int) p1.x, c.y - (int) p1.y);
        g.drawLine(c.x, c.y, c.x + (int) p2.x, c.y - (int) p2.y);
    }
}
 
开发者ID:sdghrmz,项目名称:jvircam,代码行数:35,代码来源:SideViewPanel.java

示例10: paintComponent

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g); //To change body of generated methods, choose Tools | Templates.
    Point o = this.getWorldCenter();
    // x axis
    g.setColor(Constants.XAxis_Color);
    g.drawLine(o.x, o.y, this.getWidth(), o.y);
    // y axis
    g.setColor(Constants.YAxis_Color);
    g.drawLine(o.x, o.y, o.x, 0);

    g.setColor(Constants.Origin_Color);
    g.drawOval(o.x - Constants.Origin_Radius, o.y - Constants.Origin_Radius, 2 * Constants.Origin_Radius, 2 * Constants.Origin_Radius);

    if (camera != null) {
        Point c = this.getCameraLocation();
        g.setColor(Constants.Camera_Color);
        g.drawOval(c.x - Constants.Camera_Radius, c.y - Constants.Camera_Radius, 2 * Constants.Camera_Radius, 2 * Constants.Camera_Radius);

        double hfv = camera.getHorizontalFieldOfView() / 2;
        double pan = camera.getPanAngle();
        Point3d p1 = new Point3d(this.getWidth(), 0, 0);
        Point3d p2 = new Point3d(this.getWidth(), 0, 0);
        Matrix3d rot = new Matrix3d();
        rot.rotZ(pan + hfv);
        rot.transform(p1);
        rot.rotZ(pan - hfv);
        rot.transform(p2);
        g.setColor(Constants.FOV_Color);
        g.drawLine(c.x, c.y, c.x + (int) p1.x, c.y - (int) p1.y);
        g.drawLine(c.x, c.y, c.x + (int) p2.x, c.y - (int) p2.y);
    }
}
 
开发者ID:sdghrmz,项目名称:jvircam,代码行数:34,代码来源:TopViewPanel.java

示例11: getVertices

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public Point3d[] getVertices() {
	Point3d[] icosahedron = new Point3d[12];
	// see http://answers.yahoo.com/question/index?qid=20080108041441AAJCjEu
	double c = circumscribedRadius * 1 / Math.sqrt(5);
	double s = 2 * c; // golden ratio
	double c1 = Math.sqrt((3-Math.sqrt(5))/8); // cos(2Pi/5)
	double s1 = Math.sqrt((5+Math.sqrt(5))/8); // sin(2Pi/5)
	double c2 = Math.sqrt((3+Math.sqrt(5))/8); // cos(Pi/5)
	double s2 = Math.sqrt((5-Math.sqrt(5))/8); // sin(Pi/5)

	icosahedron[0] = new Point3d(0, 0, circumscribedRadius);
	icosahedron[1] = new Point3d(s, 0, c);
	icosahedron[2] = new Point3d(s*c1, s*s1, c);
	icosahedron[3] = new Point3d(-s*c2, s*s2, c);
	icosahedron[4] = new Point3d(-s*c2, -s*s2, c);
	icosahedron[5] = new Point3d(s*c1, -s*s1, c);
	for (int i = 0; i < 6; i++) {
		icosahedron[i+6] = new Point3d(icosahedron[i]);
		icosahedron[i+6].negate();
	}

	Matrix3d m = new Matrix3d();
	m.rotZ(Math.PI/10);
	for (Point3d p: icosahedron) {
		m.transform(p);
	}

	return icosahedron;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:31,代码来源:Icosahedron.java

示例12: getPolygonVertices

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Returns the vertices of an n-fold polygon of given radius and center
 * @return
 */
public static Point3d[] getPolygonVertices(int n, double radius, Point3d center) {
	Point3d[] polygon = new Point3d[n];
	Matrix3d m = new Matrix3d();

	for (int i = 0; i < n; i++) {
		polygon[i] = new Point3d(0, radius, 0);
		m.rotZ(i*2*Math.PI/n);
		m.transform(polygon[i]);
		polygon[i].add(center);
	}
	return polygon;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:17,代码来源:Prism.java

示例13: SparkySpacecraftMat

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Initialize with input scale factor.
 * 
 * @param    scale    Scale factor for the model.  A scale of
 *                    1.0 means the distance from the model origin, to the
 *                    furthest point on the model, will be one unit long.
 */
public SparkySpacecraftMat(double scale) {
    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymatmesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL = SparkySpacecraftMat.class.getResource("sparkymatmesh.obj");
    if (sparkyURL == null) {
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    modelScene = of.load(sparkyURL);
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    BranchGroup modelBG = modelScene.getSceneGroup();
      //
    tg.addChild(modelBG);
    addChild(tg);
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:47,代码来源:SparkySpacecraftMat.java

示例14: Hexacopter

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Generic hexacopter constructor.
 *
 * @param world          world where to place the vehicle
 * @param modelName      filename of model to load, in .obj format
 * @param orientation    "x" or "+"
 * @param armLength      length of arm from center
 * @param rotorThrust    full thrust of one rotor
 * @param rotorTorque    torque at full thrust of one rotor
 * @param rotorTimeConst spin-up time of rotor
 * @param rotorsOffset   rotors positions offset from gravity center
 * @throws FileNotFoundException if .obj model file not found
 */
public Hexacopter(World world, String modelName, String orientation, double armLength, double rotorThrust,
                  double rotorTorque, double rotorTimeConst, Vector3d rotorsOffset) throws FileNotFoundException {
    super(world, modelName);
    rotorPositions[0] = new Vector3d(armLength, 0.0, 0.0);
    rotorPositions[1] = new Vector3d(-armLength, 0.0, 0.0);
    rotorPositions[2] = new Vector3d(-armLength * Math.cos(Math.PI / 3), -armLength * Math.sin(Math.PI / 3), 0.0);
    rotorPositions[3] = new Vector3d(armLength * Math.cos(Math.PI / 3), armLength * Math.sin(Math.PI / 3), 0.0);
    rotorPositions[4] = new Vector3d(armLength * Math.cos(Math.PI / 3), -armLength * Math.sin(Math.PI / 3), 0.0);
    rotorPositions[5] = new Vector3d(-armLength * Math.cos(Math.PI / 3), armLength * Math.sin(Math.PI / 3), 0.0);
    if (orientation.equals("x") || orientation.equals("X")) {
        Matrix3d r = new Matrix3d();
        r.rotZ(Math.PI / 2);
        for (int i = 0; i < rotorsNum; i++) {
            r.transform(rotorPositions[i]);
        }
    } else if (orientation.equals("+")) {
    } else {
        throw new RuntimeException("Unknown orientation: " + orientation);
    }
    for (int i = 0; i < rotors.length; i++) {
        rotorPositions[i].add(rotorsOffset);
        Rotor rotor = rotors[i];
        rotor.setFullThrust(rotorThrust);
        rotor.setFullTorque((i == 1 || i == 3 || i == 4) ? -rotorTorque : rotorTorque);
        rotor.setTimeConstant(rotorTimeConst);
    }
}
 
开发者ID:DrTon,项目名称:jMAVSim,代码行数:41,代码来源:Hexacopter.java

示例15: TestSpacecraft

import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
 * Initialize with input scale factor.  The model BranchGroup is retained
 * allowing for the getMassDyadic function to retrieve vertex info.
 * 
 * @param    scale    Scale factor for the model.  A scale of
 */
public TestSpacecraft(double scale) {
  sf = (float) scale;
    // allow the state of the model to be changed after compilation
  setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
  setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // add the visual representation to the TransformGroup
  try {
      // first try the sparkymatmesh.obj model
    Scene modelScene = null;
    ObjectFile of = new ObjectFile();
    of.setFlags(ObjectFile.RESIZE     |
               ObjectFile.TRIANGULATE |
               ObjectFile.STRIPIFY);   
      // load the mesh defined below
    URL sparkyURL = TestSpacecraft.class.getResource("sparkymatmesh.obj");
    if (sparkyURL == null) {
      System.out.println("Can't find sphere.obj");
      throw new java.io.FileNotFoundException("Can't find sparkymesh.obj" +
                                                                       this);
    }
    
    modelScene = of.load(sparkyURL);
    
      // rotate model axis to align with simulation axis.  Also, offset
      // it along the x-axis so the cg and origin coincide.
    Vector3d trans = new Vector3d();  // offset along x-axis
    trans.x = XOFF*scale;
    Matrix3d m1 = new Matrix3d();
    m1.rotX(Math.PI/2.0);          // nose down into plane
    Matrix3d m2 = new Matrix3d();
    m2.rotZ(Math.PI/2.0);          // nose yaw into X
    m2.mul(m1);                    // combine
    Transform3D t3d = new Transform3D(m2, trans, scale);
    TransformGroup tg = new TransformGroup(t3d);
    modelBG = modelScene.getSceneGroup();
    
    tg.addChild(modelBG);
    addChild(tg);
  } catch(java.io.FileNotFoundException ex) {
      // if the above didn't work, load a sphere
    addChild(new Sphere(1.0f));
  }
}
 
开发者ID:motoq,项目名称:vse,代码行数:50,代码来源:TestSpacecraft.java


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