本文整理汇总了Java中javax.vecmath.Matrix3d.set方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix3d.set方法的具体用法?Java Matrix3d.set怎么用?Java Matrix3d.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix3d
的用法示例。
在下文中一共展示了Matrix3d.set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: getRotationMatrix
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Create a matrix that rotates around the specified axis by the specified angle.
*
* @param axis The axis
* @param radians The angle in radians
* @return The rotation matrix
*/
public static Matrix3d getRotationMatrix(EnumFacing.Axis axis, double radians) {
final Vec3i axisDirectionVector = AXIS_DIRECTION_VECTORS.get(axis);
final AxisAngle4d axisAngle = new AxisAngle4d(axisDirectionVector.getX(), axisDirectionVector.getY(), axisDirectionVector.getZ(), radians);
final Matrix3d rotationMatrix = new Matrix3d();
rotationMatrix.set(axisAngle);
return rotationMatrix;
}
示例3: 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;
}
示例4: 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 );
}
示例5: getRotation
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Places the rotational component of the camera transform in <code>result</code> and returns it.
*/
public Matrix3d getRotation( Matrix3d result )
{
updateRotation( );
result.set( rotation );
return result;
}
示例6: turn
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public void turn(Vector3d axis, int stroke, GFigure figure) {
double angle = stroke * GCameraSpinner.SPIN_ANGLE;
AxisAngle4d axisAngle = new AxisAngle4d(axis, angle);
Matrix3d rotMatrix = new Matrix3d();
rotMatrix.set(axisAngle);
rotMatrix.mulNormalize(attitude);
attitude.set(rotMatrix);
figure.cameraTurned();
}
示例7: defaultAttitude
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public static Matrix3d defaultAttitude() {
AxisAngle4d axisAngle1 = new AxisAngle4d(1, 1, 1, -Math.PI * 2 / 3);
Matrix3d m1 = new Matrix3d();
m1.set(axisAngle1);
AxisAngle4d axisAngle2 = new AxisAngle4d(0, 1, 0, Math.PI / 7);
Matrix3d m2 = new Matrix3d();
m2.set(axisAngle2);
AxisAngle4d axisAngle3 = new AxisAngle4d(1, 0, 0, Math.PI / 15);
Matrix3d m3 = new Matrix3d();
m3.set(axisAngle3);
m2.mul(m1);
m3.mul(m2);
return m3;
}
示例8: 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;
}
示例9: GCamera
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
public GCamera() {
initialAttitude = new Matrix3d();
initialAttitude.set(defaultAttitude());
attitude = new Matrix3d();
attitude.set(initialAttitude);
}
示例10: findPoint
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
/**
* Locate a coordinate at a specific distance (km), elevation angle
* (radians), and heading (radians) from this one.
*/
public EarthVector findPoint(
final double distanceKM,
final double azimuth,
final double elevAngle ) {
// convert distance to radians
// final double distR = distanceKM / KMPerDegree() / DPR;
final double lon = getLongitude();
final double lat = getLatitude();
// convert local enu to ecf to get east and north vectors
// east vector
final Vector3d eastVec = new Vector3d(
1,
0,
0);
final Vector3d northVec = new Vector3d(
0,
1,
0);
final double sinLon = Math.sin(lon);
final double cosLon = Math.cos(lon);
final double sinLat = Math.sin(lat);
final double cosLat = Math.cos(lat);
final Matrix3d enuToEcf = new Matrix3d();
enuToEcf.m00 = -sinLon;
enuToEcf.m01 = -(sinLat * cosLon);
enuToEcf.m02 = cosLat * cosLon;
enuToEcf.m10 = cosLon;
enuToEcf.m11 = -(sinLat * sinLon);
enuToEcf.m12 = cosLat * sinLon;
enuToEcf.m20 = 0;
enuToEcf.m21 = cosLat;
enuToEcf.m22 = sinLat;
enuToEcf.transform(eastVec);
enuToEcf.transform(northVec);
eastVec.normalize();
northVec.normalize();
northVec.scale(distanceKM);
final Matrix3d elevTrans = new Matrix3d();
elevTrans.set(new AxisAngle4d(
eastVec,
elevAngle));
elevTrans.transform(northVec);
final Matrix3d azTrans = new Matrix3d();
final Vector3d unitEcf = new Vector3d(
ecfVector);
unitEcf.normalize();
azTrans.set(new AxisAngle4d(
unitEcf,
azimuth));
azTrans.transform(northVec);
final Vector3d transformedEcf = new Vector3d();
transformedEcf.add(
ecfVector,
northVec);
final EarthVector transformedEv = new EarthVector(
transformedEcf);
return transformedEv;
}
示例11: update
import javax.vecmath.Matrix3d; //导入方法依赖的package包/类
@Override
public void update(long t) {
if (lastTime >= 0) {
double dt = (t - lastTime) / 1000.0;
if (dt < 0.001) {
dt = 0.001; // Limit min dt to 1ms
}
// Position
Vector3d dPos = new Vector3d(velocity);
dPos.scale(dt);
position.add(dPos);
// Velocity
acceleration = getForce();
acceleration.scale(1.0 / mass);
acceleration.add(getWorld().getEnvironment().getG());
if (position.z >= getWorld().getEnvironment().getGroundLevel(position) &&
velocity.z + acceleration.z * dt >= 0.0) {
// On ground
acceleration.x = -velocity.x / dt;
acceleration.y = -velocity.y / dt;
acceleration.z = -velocity.z / dt;
position.z = getWorld().getEnvironment().getGroundLevel(position);
//rotationRate.set(0.0, 0.0, 0.0);
}
Vector3d dVel = new Vector3d(acceleration);
dVel.scale(dt);
velocity.add(dVel);
// Rotation
if (rotationRate.length() > 0.0) {
Matrix3d r = new Matrix3d();
Vector3d rotationAxis = new Vector3d(rotationRate);
rotationAxis.normalize();
r.set(new AxisAngle4d(rotationAxis, rotationRate.length() * dt));
rotation.mulNormalize(r);
}
// Rotation rate
Vector3d Iw = new Vector3d(rotationRate);
momentOfInertia.transform(Iw);
Vector3d angularAcc = new Vector3d();
angularAcc.cross(rotationRate, Iw);
angularAcc.negate();
angularAcc.add(getTorque());
momentOfInertiaInv.transform(angularAcc);
angularAcc.scale(dt);
rotationRate.add(angularAcc);
}
lastTime = t;
}