本文整理汇总了Java中com.badlogic.gdx.math.Matrix3类的典型用法代码示例。如果您正苦于以下问题:Java Matrix3类的具体用法?Java Matrix3怎么用?Java Matrix3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Matrix3类属于com.badlogic.gdx.math包,在下文中一共展示了Matrix3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatrix
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static native void getMatrix(JavaScriptObject matrix3InJS, Matrix3 matrix3Out) /*-{
var row0 = matrix3InJS.getRow(0);
var row1 = matrix3InJS.getRow(1);
var row2 = matrix3InJS.getRow(2);
var x0 = row0.x();
var y0 = row0.y();
var z0 = row0.z();
var x1 = row1.x();
var y1 = row1.y();
var z1 = row1.z();
var x2 = row2.x();
var y2 = row2.y();
var z2 = row2.z();
[email protected]::val[0] = x0;
[email protected]::val[1] = y0;
[email protected]::val[2] = z0;
[email protected]::val[3] = x1;
[email protected]::val[4] = y1;
[email protected]::val[5] = z1;
[email protected]::val[6] = x2;
[email protected]::val[7] = y2;
[email protected]::val[8] = z2;
}-*/;
示例2: getMatrix
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public Matrix4 getMatrix(Matrix4 out) {
out.val[Matrix4.M00] = basis.val[Matrix3.M00];
out.val[Matrix4.M01] = basis.val[Matrix3.M01];
out.val[Matrix4.M02] = basis.val[Matrix3.M02];
out.val[Matrix4.M03] = origin.x;
out.val[Matrix4.M10] = basis.val[Matrix3.M10];
out.val[Matrix4.M11] = basis.val[Matrix3.M11];
out.val[Matrix4.M12] = basis.val[Matrix3.M12];
out.val[Matrix4.M13] = origin.y;
out.val[Matrix4.M20] = basis.val[Matrix3.M20];
out.val[Matrix4.M21] = basis.val[Matrix3.M21];
out.val[Matrix4.M22] = basis.val[Matrix3.M22];
out.val[Matrix4.M23] = origin.z;
out.val[Matrix4.M30] = 0;
out.val[Matrix4.M31] = 0;
out.val[Matrix4.M32] = 0;
out.val[Matrix4.M33] = 1;
return out;
}
示例3: getColumn
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void getColumn (Matrix3 src, int col, Vector3 v) {
if (col == 0) {
v.x = src.val[Matrix3.M00];
v.y = src.val[Matrix3.M10];
v.z = src.val[Matrix3.M20];
} else if (col == 1) {
v.x = src.val[Matrix3.M01];
v.y = src.val[Matrix3.M11];
v.z = src.val[Matrix3.M21];
} else if (col == 2) {
v.x = src.val[Matrix3.M02];
v.y = src.val[Matrix3.M12];
v.z = src.val[Matrix3.M22];
} else {
throw new GdxRuntimeException("Invalid column");
}
}
示例4: setColumn
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void setColumn (Matrix3 src, int col, Vector3 v) {
if (col == 0) {
src.val[Matrix3.M00] = v.x;
src.val[Matrix3.M10] = v.y;
src.val[Matrix3.M20] = v.z;
} else if (col == 1) {
src.val[Matrix3.M01] = v.x;
src.val[Matrix3.M11] = v.y;
src.val[Matrix3.M21] = v.z;
} else if (col == 2) {
src.val[Matrix3.M02] = v.x;
src.val[Matrix3.M12] = v.y;
src.val[Matrix3.M22] = v.z;
} else {
throw new GdxRuntimeException("Invalid column");
}
}
示例5: getRow
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void getRow (Matrix3 src, int row, Vector3 v) {
if (row == 0) {
v.x = src.val[Matrix3.M00];
v.y = src.val[Matrix3.M01];
v.z = src.val[Matrix3.M02];
} else if (row == 1) {
v.x = src.val[Matrix3.M10];
v.y = src.val[Matrix3.M11];
v.z = src.val[Matrix3.M12];
} else if (row == 2) {
v.x = src.val[Matrix3.M20];
v.y = src.val[Matrix3.M21];
v.z = src.val[Matrix3.M22];
} else {
throw new GdxRuntimeException("Invalid row");
}
}
示例6: setRow
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void setRow (Matrix3 src, int row, float x, float y, float z) {
if (row == 0) {
src.val[Matrix3.M00] = x;
src.val[Matrix3.M01] = y;
src.val[Matrix3.M02] = z;
} else if (row == 1) {
src.val[Matrix3.M10] = x;
src.val[Matrix3.M11] = y;
src.val[Matrix3.M12] = z;
} else if (row == 2) {
src.val[Matrix3.M20] = x;
src.val[Matrix3.M21] = y;
src.val[Matrix3.M22] = z;
} else {
throw new GdxRuntimeException("Invalid row");
}
}
示例7: setEulerZYX
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
/** Sets rotation matrix from euler angles. The euler angles are applied in ZYX order. This means a vector is first rotated
* about X then Y and then Z axis. */
public static void setEulerZYX (Matrix3 mat, float eulerX, float eulerY, float eulerZ) {
float ci = (float)Math.cos(eulerX);
float cj = (float)Math.cos(eulerY);
float ch = (float)Math.cos(eulerZ);
float si = (float)Math.sin(eulerX);
float sj = (float)Math.sin(eulerY);
float sh = (float)Math.sin(eulerZ);
float cc = ci * ch;
float cs = ci * sh;
float sc = si * ch;
float ss = si * sh;
setRow(mat, 0, cj * ch, sj * sc - cs, sj * cc + ss);
setRow(mat, 1, cj * sh, sj * ss + cc, sj * cs - sc);
setRow(mat, 2, -sj, cj * si, cj * ci);
}
示例8: setRotation
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void setRotation (Matrix3 dest, Quaternion q) {
float d = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
assert (d != 0f);
float s = 2f / d;
float xs = q.x * s, ys = q.y * s, zs = q.z * s;
float wx = q.w * xs, wy = q.w * ys, wz = q.w * zs;
float xx = q.x * xs, xy = q.x * ys, xz = q.x * zs;
float yy = q.y * ys, yz = q.y * zs, zz = q.z * zs;
dest.val[Matrix3.M00] = 1f - (yy + zz);
dest.val[Matrix3.M01] = xy - wz;
dest.val[Matrix3.M02] = xz + wy;
dest.val[Matrix3.M10] = xy + wz;
dest.val[Matrix3.M11] = 1f - (xx + zz);
dest.val[Matrix3.M12] = yz - wx;
dest.val[Matrix3.M20] = xz - wy;
dest.val[Matrix3.M21] = yz + wx;
dest.val[Matrix3.M22] = 1f - (xx + yy);
}
示例9: getRotation
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public static void getRotation (Matrix3 mat, Quaternion dest) {
/*
* ArrayPool<float[]> floatArrays = ArrayPool.get(float.class);
*
* float trace = mat.val[Matrix3.M00] + mat.val[Matrix3.M11] + mat.val[Matrix3.M22]; float[] temp = floatArrays.getFixed(4);
*
* if (trace > 0f) { float s = (float) Math.sqrt(trace + 1f); temp[3] = (s * 0.5f); s = 0.5f / s;
*
* temp[0] = ((mat.val[Matrix3.M21] - mat.val[Matrix3.M12]) * s); temp[1] = ((mat.val[Matrix3.M02] - mat.val[Matrix3.M20]) *
* s); temp[2] = ((mat.val[Matrix3.M10] - mat.val[Matrix3.M01]) * s); } else { int i = mat.val[Matrix3.M00] <
* mat.val[Matrix3.M11] ? (mat.val[Matrix3.M11] < mat.val[Matrix3.M22] ? 2 : 1) : (mat.val[Matrix3.M00] <
* mat.val[Matrix3.M22] ? 2 : 0); int j = (i + 1) % 3; int k = (i + 2) % 3;
*
* float s = (float) Math.sqrt(mat.getElement(i, i) - mat.getElement(j, j) - mat.getElement(k, k) + 1f); temp[i] = s * 0.5f;
* s = 0.5f / s;
*
* temp[3] = (mat.getElement(k, j) - mat.getElement(j, k)) * s; temp[j] = (mat.getElement(j, i) + mat.getElement(i, j)) * s;
* temp[k] = (mat.getElement(k, i) + mat.getElement(i, k)) * s; } dest.set(temp[0], temp[1], temp[2], temp[3]);
*
* floatArrays.release(temp);
*/
// FIXME check this is correct
dest.setFromMatrix(true, mat);
}
示例10: init
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
/** Constraint between two different rigidbodies. */
public void init (Matrix3 world2A, Matrix3 world2B, Vector3 rel_pos1, Vector3 rel_pos2, Vector3 jointAxis, Vector3 inertiaInvA,
float massInvA, Vector3 inertiaInvB, float massInvB) {
linearJointAxis.set(jointAxis);
aJ.set(rel_pos1).crs(linearJointAxis);
aJ.mul(world2A);
bJ.set(linearJointAxis);
bJ.scl(-1);
bJ.set(rel_pos2).crs(bJ);
bJ.mul(world2B);
VectorUtil.mul(m_0MinvJt, inertiaInvA, aJ);
VectorUtil.mul(m_1MinvJt, inertiaInvB, bJ);
Adiag = massInvA + m_0MinvJt.dot(aJ) + massInvB + m_1MinvJt.dot(bJ);
assert (Adiag > 0f);
}
示例11: HingeConstraint
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public HingeConstraint (RigidBody rbA, RigidBody rbB, Transform rbAFrame, Transform rbBFrame) {
super(TypedConstraintType.HINGE_CONSTRAINT_TYPE, rbA, rbB);
this.rbAFrame.set(rbAFrame);
this.rbBFrame.set(rbBFrame);
angularOnly = false;
enableAngularMotor = false;
// flip axis
this.rbBFrame.basis.val[Matrix3.M02] *= -1f;
this.rbBFrame.basis.val[Matrix3.M12] *= -1f;
this.rbBFrame.basis.val[Matrix3.M22] *= -1f;
// start with free
lowerLimit = 1e30f;
upperLimit = -1e30f;
biasFactor = 0.3f;
relaxationFactor = 1.0f;
limitSoftness = 0.9f;
solveLimit = false;
}
示例12: buildLinearJacobian
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
protected void buildLinearJacobian (/* JacobianEntry jacLinear */int jacLinear_index, Vector3 normalWorld, Vector3 pivotAInW,
Vector3 pivotBInW) {
Stack stack = Stack.enter();
Matrix3 mat1 = rbA.getCenterOfMassTransform(stack.allocTransform()).basis;
mat1.transpose();
Matrix3 mat2 = rbB.getCenterOfMassTransform(stack.allocTransform()).basis;
mat2.transpose();
Vector3 tmpVec = stack.allocVector3();
Vector3 tmp1 = stack.allocVector3();
tmp1.set(pivotAInW).sub(rbA.getCenterOfMassPosition(tmpVec));
Vector3 tmp2 = stack.allocVector3();
tmp2.set(pivotBInW).sub(rbB.getCenterOfMassPosition(tmpVec));
jacLinear[jacLinear_index].init(mat1, mat2, tmp1, tmp2, normalWorld, rbA.getInvInertiaDiagLocal(stack.allocVector3()),
rbA.getInvMass(), rbB.getInvInertiaDiagLocal(stack.allocVector3()), rbB.getInvMass());
stack.leave();
}
示例13: getTypeName
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
private String getTypeName() {
if (customType != null) {
return customType;
} else if (type == Matrix4.class) {
return "mat4";
} else if (type == Float.class) {
return "float";
} else if (type == Matrix3.class) {
return "mat3";
} else if (type == Vector2.class) {
return "vec2";
} else if (type == Vector3.class || type == Color.class) {
return "vec4";
} else if (type == Texture.class) {
return "sampler2D";
}
throw new GdxRuntimeException("Undefined type: " + type + " for " + name);
}
示例14: set
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
/**
* Sets this matrix to the given 3x3 matrix. The third column of this matrix
* is set to (0,0,1,0).
*
* @param mat
* the matrix
*/
public Matrix4d set(Matrix3 mat) {
val[0] = mat.val[0];
val[1] = mat.val[1];
val[2] = mat.val[2];
val[3] = 0;
val[4] = mat.val[3];
val[5] = mat.val[4];
val[6] = mat.val[5];
val[7] = 0;
val[8] = 0;
val[9] = 0;
val[10] = 1;
val[11] = 0;
val[12] = mat.val[6];
val[13] = mat.val[7];
val[14] = 0;
val[15] = mat.val[8];
return this;
}
示例15: getWorldTransform
import com.badlogic.gdx.math.Matrix3; //导入依赖的package包/类
public Matrix3 getWorldTransform (Matrix3 worldTransform) {
if (worldTransform == null) throw new IllegalArgumentException("worldTransform cannot be null.");
float[] val = worldTransform.val;
val[M00] = a;
val[M01] = b;
val[M10] = c;
val[M11] = d;
val[M02] = worldX;
val[M12] = worldY;
val[M20] = 0;
val[M21] = 0;
val[M22] = 1;
return worldTransform;
}