本文整理汇总了Java中javax.vecmath.Matrix3d.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix3d.transform方法的具体用法?Java Matrix3d.transform怎么用?Java Matrix3d.transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix3d
的用法示例。
在下文中一共展示了Matrix3d.transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rotateAABB
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Rotate an {@link AxisAlignedBB} by the specified rotation matrix.
*
* @param axisAlignedBB The AABB
* @param rotationMatrix The rotation matrix
* @param forcePositive If true, set each coordinate of the rotated AABB to it absolute value
* @return The rotated AABB
*/
public static AxisAlignedBB rotateAABB(AxisAlignedBB axisAlignedBB, Matrix3d rotationMatrix, boolean forcePositive) {
// Extract the minimum and maximum coordinates of the AABB into vectors
final Vector3d minCoords = new Vector3d(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
final Vector3d maxCoords = new Vector3d(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
// Rotate the vectors in-place
rotationMatrix.transform(minCoords);
rotationMatrix.transform(maxCoords);
if (forcePositive) {
// Get the absolute value of the coordinates
minCoords.absolute();
maxCoords.absolute();
}
// Return an AABB with the new coordinates
return new AxisAlignedBB(minCoords.getX(), minCoords.getY(), minCoords.getZ(), maxCoords.getX(), maxCoords.getY(), maxCoords.getZ());
}
示例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);
}
}
}
}
示例3: getProjection
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public Projection getProjection() {
double fx = focalLength * resolution.x / sensorSize.x;
double fy = focalLength * resolution.y / sensorSize.y;
Matrix3d K = new Matrix3d(fx, 0, center.x, 0, fy, center.y, 0, 0, 1);
//K.setIdentity();
Matrix3d R = new Matrix3d(this.rotation);
R.transpose();
VirtualCamera.logFrame().log(R.toString());
Vector3d T = new Vector3d(this.position);
T.scale(-1);
R.transform(T);
projection.set(new Projection(K, R, T));
return this.projection;
}
示例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: 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;
}
示例6: 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);
}
}
示例7: quatRotate
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public Vector3d quatRotate(Quat4d r, Vector3d v) {
Matrix3d rotMat = new Matrix3d();
rotMat.set(r);
Vector3d result = new Vector3d();
rotMat.transform(v, result);
return result;
}
示例8: callbackRender
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Calculate the angles and call them back to the app
* @param inFunction function to call (either pov or svg)
*/
private void callbackRender(Export3dFunction inFunction)
{
Transform3D trans3d = new Transform3D();
_orbit.getViewingPlatform().getViewPlatformTransform().getTransform(trans3d);
Matrix3d matrix = new Matrix3d();
trans3d.get(matrix);
Point3d point = new Point3d(0.0, 0.0, 1.0);
matrix.transform(point);
// Set up initial rotations
Transform3D firstTran = new Transform3D();
firstTran.rotY(Math.toRadians(-INITIAL_Y_ROTATION));
Transform3D secondTran = new Transform3D();
secondTran.rotX(Math.toRadians(-INITIAL_X_ROTATION));
// Apply inverse rotations in reverse order to the test point
Point3d result = new Point3d();
secondTran.transform(point, result);
firstTran.transform(result);
// Give the settings to the rendering function
inFunction.setCameraCoordinates(result.x, result.y, result.z);
inFunction.setAltitudeExaggeration(_altFactor);
inFunction.setTerrainDefinition(_terrainDefinition); // ignored by svg, used by pov
inFunction.setImageDefinition(_imageDefinition); // ignored by svg, used by pov
inFunction.begin();
}
示例9: addViewpointRotation
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public void addViewpointRotation( Quat4d rotation )
{
Matrix3d m = new Matrix3d();
m .set( rotation );
m .invert();
m .transform( mLookDirection );
m .transform( mUpDirection );
}
示例10: project
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public void project(GCamera camera, Point3d centerCoords) {
Matrix3d attitude = camera.getAttitude();
Point3d css = new Point3d(coords);
css.sub(centerCoords);
Point3d cs = new Point3d();
attitude.transform(css, cs);
projCoords = new Point2d(cs.x, cs.y);
}
示例11: Projection
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public Projection(Matrix3d K, Matrix3d R, Vector3d T) {
this.K = K;
this.R = R;
this.T = T;
Matrix3d KR = new Matrix3d(K);
KR.mul(R);
Vector3d KT = new Vector3d(T);
K.transform(KT);
P = new Transform3D();
P.setIdentity();
P.setRotation(KR);
P.setTranslation(KT);
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: rotate
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Rotates this coordinate about the input vector through the input angle
* (radians - because we usually use this internally)
*
* @param vecAxis
* The axis of rotation
* @param ang
* The angle of rotation (in radians)
*/
// public Vector3d rotate( Vector3d vecAxis, double ang )
// {
// Vector3d vec1 = new Vector3d(vecAxis);
// vec1.normalize();
// Vector3d vec2 = new Vector3d();
// vec2.cross(vec1, ecfVector);
// Vector3d vec3 = new Vector3d();
// vec3.cross(vec2, vec1);
//
// double ang_sin = Math.sin(ang);
// double ang_cos = Math.cos(ang) - 1.0;
//
// Vector3d result = new Vector3d();
// result.x = ecfVector.x + ang_cos*vec3.x + ang_sin*vec2.x;
// result.y = ecfVector.y + ang_cos*vec3.y + ang_sin*vec2.y;
// result.z = ecfVector.z + ang_cos*vec3.z + ang_sin*vec2.z;
//
// return result;
// }
public Vector3d rotate(
final Vector3d rotAxis,
final double angle ) {
final Vector3d thisVec = new Vector3d(
ecfVector);
final Vector3d axis = new Vector3d(
rotAxis);
axis.normalize();
final Matrix3d trans = new Matrix3d();
trans.set(new AxisAngle4d(
axis,
angle));
trans.transform(thisVec);
return thisVec;
}
示例15: 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;
}