本文整理汇总了Java中javax.vecmath.Matrix3f.setIdentity方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix3f.setIdentity方法的具体用法?Java Matrix3f.setIdentity怎么用?Java Matrix3f.setIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix3f
的用法示例。
在下文中一共展示了Matrix3f.setIdentity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BulletPhysics
import javax.vecmath.Matrix3f; //导入方法依赖的package包/类
public BulletPhysics(WorldProvider world) {
collisionGroupManager = CoreRegistry.get(CollisionGroupManager.class);
_broadphase = new DbvtBroadphase();
_broadphase.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
_defaultCollisionConfiguration = new DefaultCollisionConfiguration();
_dispatcher = new CollisionDispatcher(_defaultCollisionConfiguration);
_sequentialImpulseConstraintSolver = new SequentialImpulseConstraintSolver();
_discreteDynamicsWorld = new DiscreteDynamicsWorld(_dispatcher, _broadphase, _sequentialImpulseConstraintSolver, _defaultCollisionConfiguration);
_discreteDynamicsWorld.setGravity(new Vector3f(0f, -15f, 0f));
blockEntityRegistry = CoreRegistry.get(BlockEntityRegistry.class);
CoreRegistry.get(EventSystem.class).registerEventReceiver(this, BlockChangedEvent.class, BlockComponent.class);
PhysicsWorldWrapper wrapper = new PhysicsWorldWrapper(world);
VoxelWorldShape worldShape = new VoxelWorldShape(wrapper);
Matrix3f rot = new Matrix3f();
rot.setIdentity();
DefaultMotionState blockMotionState = new DefaultMotionState(new Transform(new Matrix4f(rot, new Vector3f(0, 0, 0), 1.0f)));
RigidBodyConstructionInfo blockConsInf = new RigidBodyConstructionInfo(0, blockMotionState, worldShape, new Vector3f());
RigidBody rigidBody = new RigidBody(blockConsInf);
rigidBody.setCollisionFlags(CollisionFlags.STATIC_OBJECT | rigidBody.getCollisionFlags());
_discreteDynamicsWorld.addRigidBody(rigidBody, combineGroups(StandardCollisionGroup.WORLD), (short)(CollisionFilterGroups.ALL_FILTER ^ CollisionFilterGroups.STATIC_FILTER));
}
示例2: calculateBodyRotation
import javax.vecmath.Matrix3f; //导入方法依赖的package包/类
/**
* BodyのWorld座標系での回転行列(pitch, rollのみ)を返します.
*
* @param context
* @param mat
*/
private void calculateBodyRotation(SomaticContext context, Matrix3f mat) {
// FIXME 未テスト
Matrix3f rot;
if (context.isLeftOnGround())
rot = context.get(Frames.LSole).getBodyRotation();
else if (context.isRightOnGround())
rot = context.get(Frames.RSole).getBodyRotation();
else {
mat.setIdentity();
return;
}
Vector3f tmp = new Vector3f();
MatrixUtils.rot2pyr(rot, tmp);
tmp.y = 0;
MatrixUtils.pyr2rot(tmp, mat);
}
示例3: stepJacobi
import javax.vecmath.Matrix3f; //导入方法依赖的package包/类
private static Quat4f stepJacobi(Matrix3f m)
{
Matrix3f t = new Matrix3f();
Quat4f qt = new Quat4f(), ret = new Quat4f(0, 0, 0, 1);
Pair<Float, Float> p;
// 01
if(m.m01 * m.m01 + m.m10 * m.m10 > eps)
{
p = approxGivensQuat(m.m00, .5f * (m.m01 + m.m10), m.m11);
qt.set(0, 0, p.getLeft(), p.getRight());
//qt.normalize();
ret.mul(qt);
//t.set(qt);
t.setIdentity();
t.m00 = qt.w * qt.w - qt.z * qt.z;
t.m11 = t.m00;
t.m10 = 2 * qt.z * qt.w;
t.m01 = -t.m10;
t.m22 = qt.w * qt.w + qt.z * qt.z;
m.mul(m, t);
t.transpose();
m.mul(t, m);
}
// 02
if(m.m02 * m.m02 + m.m20 * m.m20 > eps)
{
p = approxGivensQuat(m.m00, .5f * (m.m02 + m.m20), m.m22);
qt.set(0, -p.getLeft(), 0, p.getRight());
//qt.normalize();
ret.mul(qt);
//t.set(qt);
t.setIdentity();
t.m00 = qt.w * qt.w - qt.y * qt.y;
t.m22 = t.m00;
t.m20 = -2 * qt.y * qt.w;
t.m02 = -t.m20;
t.m11 = qt.w * qt.w + qt.y * qt.y;
m.mul(m, t);
t.transpose();
m.mul(t, m);
}
// 12
if(m.m12 * m.m12 + m.m21 * m.m21 > eps)
{
p = approxGivensQuat(m.m11, .5f * (m.m12 + m.m21), m.m22);
qt.set(p.getLeft(), 0, 0, p.getRight());
//qt.normalize();
ret.mul(qt);
//t.set(qt);
t.setIdentity();
t.m11 = qt.w * qt.w - qt.x * qt.x;
t.m22 = t.m11;
t.m21 = 2 * qt.x * qt.w;
t.m12 = -t.m21;
t.m00 = qt.w * qt.w + qt.x * qt.x;
m.mul(m, t);
t.transpose();
m.mul(t, m);
}
return ret;
}
示例4: diagonalize
import javax.vecmath.Matrix3f; //导入方法依赖的package包/类
public static void diagonalize(Matrix3f m_el, Matrix3f rot, float threshold, int maxSteps) {
rot.setIdentity();
for (int step = maxSteps; step > 0; step--) {
int p = 0;
int q = 1;
int r = 2;
float max = Math.abs(m_el.getElement(0, 1));
float v = Math.abs(m_el.getElement(0, 2));
if (v > max) {
p = 1;
q = 2;
r = 0;
max = v;
}
float t = threshold * Math.abs(m_el.getElement(0, 0)) + Math.abs(m_el.getElement(1, 1)) + Math.abs(m_el.getElement(2, 2));
if (max <= t) {
if (max <= BulletGlobals.SIMD_EPSILON * t) {
return;
}
step = 1;
}
float mpq = m_el.getElement(p, q);
float theta = m_el.getElement(q, q) - m_el.getElement(p, p) / (2 * mpq);
float theta2 = theta * theta;
float cos;
float sin;
if (theta2 * theta2 < 10f / BulletGlobals.SIMD_EPSILON) {
t = (theta >= 0)? 1f / (theta + (float)Math.sqrt(.5f / theta2))
: 1f / (theta - (float)Math.sqrt(1 + theta2));
cos = 1 / (float)Math.sqrt(1 + t * t);
sin = cos * t;
} else {
t = 1f / (theta * (2 + .5f / theta2));
cos = 1 - .5f * t * t;
sin = cos * t;
}
m_el.setElement(p, q, 0);
m_el.setElement(q, p, 0);
m_el.setElement(p, p, m_el.getElement(p, p) - t * mpq);
m_el.setElement(q, q, m_el.getElement(q, q) + t * mpq);
float mrp = m_el.getElement(r, p);
float mrq = m_el.getElement(r, q);
float tmp1 = cos * mrp - sin * mrq;
m_el.setElement(r, p, tmp1);
m_el.setElement(p, r, tmp1);
m_el.setElement(r, q, tmp1);
m_el.setElement(q, r, tmp1);
Vector3f row = new Vector3f();
for (int i = 0; i < 3; i++) {
m_el.getRow(i, row);
mrp = VectorUtil.getCoord(row, p);
mrq = VectorUtil.getCoord(row, q);
VectorUtil.setCoord(row, p, cos * mrp - sin * mrq);
VectorUtil.setCoord(row, q, cos * mrq - sin * mrp);
}
}
}
示例5: getGpsRotation
import javax.vecmath.Matrix3f; //导入方法依赖的package包/类
@Override
public void getGpsRotation(Matrix3f mat) {
// disabled in webots6
mat.setIdentity();
}