本文整理汇总了Java中javax.vecmath.Matrix3d.rotX方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix3d.rotX方法的具体用法?Java Matrix3d.rotX怎么用?Java Matrix3d.rotX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix3d
的用法示例。
在下文中一共展示了Matrix3d.rotX方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: 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);
}
示例3: 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;
}
示例4: getVertices
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Returns the vertices of an n-fold polygon of given radius and center
* @param n
* @param radius
* @param center
* @return
*/
@Override
public Point3d[] getVertices() {
double x = getSideLengthFromCircumscribedRadius(circumscribedRadius)/2;
double z = x/Math.sqrt(2);
Point3d[] tetrahedron = new Point3d[4];
tetrahedron[0] = new Point3d(-x, 0, -z);
tetrahedron[1] = new Point3d( x, 0, -z);
tetrahedron[2] = new Point3d( 0, -x, z);
tetrahedron[3] = new Point3d( 0, x, z);
Point3d centroid = CalcPoint.centroid(tetrahedron);
// rotate tetrahedron to align one vertex with the +z axis
Matrix3d m = new Matrix3d();
m.rotX(0.5 * TETRAHEDRAL_ANGLE);
for (Point3d p: tetrahedron) {
p.sub(centroid);
m.transform(p);
}
return tetrahedron;
}
示例5: getViewMatrix
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public Matrix3d getViewMatrix(int index) {
Matrix3d m = new Matrix3d();
switch (index) {
case 0:
m.setIdentity(); // front
break;
case 1:
m.rotX(Math.PI/2); // side edge-centered
break;
case 2:
m.rotY(Math.PI/n); // side face-centered
Matrix3d m1 = new Matrix3d();
m1.rotX(Math.PI/2);
m.mul(m1);
break;
case 3:
m.set(flipX()); // back
break;
default:
throw new IllegalArgumentException("getViewMatrix: index out of range:" + index);
}
return m;
}
示例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;
}
示例7: getViewMatrix
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public Matrix3d getViewMatrix(int index) {
Matrix3d m = new Matrix3d();
switch (index) {
case 0: m.setIdentity(); // front
break;
case 1: m.rotY(Math.PI/2); // left
break;
case 2: m.rotY(Math.PI); // back
break;
case 3: m.rotY(-Math.PI/2); // right
break;
case 4: m.rotX(Math.PI/2); // top
break;
case 5: m.rotX(-Math.PI/2); // bottom
break;
default: throw new IllegalArgumentException("getViewMatrix: index out of range:" + index);
}
return m;
}
示例8: createRotationOx
import javax.vecmath.Matrix3d; //导入方法依赖的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);
}
示例9: panTilt
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public void panTilt(double pan, double tilt) {
if (pan > -Math.PI && pan < Math.PI && tilt > -Math.PI / 2 && tilt < Math.PI / 2) {
Matrix3d ry = new Matrix3d();
ry.rotY(-pan + Math.PI / 2);
Matrix3d rx = new Matrix3d();
rx.rotX(tilt);
Matrix3d rot = new Matrix3d();
rot.rotX(-Math.PI / 2);
rot.mul(ry);
rot.mul(rx);
this.setRotation(rot);
}
}
示例10: 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(Math.PI); // back face-centered
break;
case 2: double angle = Math.PI - 0.5 * TETRAHEDRAL_ANGLE; // Side edge-centered
m.rotX(angle);
break;
default: throw new IllegalArgumentException("getViewMatrix: index out of range:" + index);
}
return m;
}
示例11: 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));
}
}
示例12: 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));
}
}