本文整理汇总了Java中com.badlogic.gdx.math.Quaternion.set方法的典型用法代码示例。如果您正苦于以下问题:Java Quaternion.set方法的具体用法?Java Quaternion.set怎么用?Java Quaternion.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Quaternion
的用法示例。
在下文中一共展示了Quaternion.set方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shortestArcQuat
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public static Quaternion shortestArcQuat (Vector3 v0, Vector3 v1, Quaternion out) {
Stack stack = Stack.enter();
Vector3 c = stack.allocVector3();
c.set(v0).crs(v1);
float d = v0.dot(v1);
if (d < -1.0 + BulletGlobals.FLT_EPSILON) {
// just pick any vector
out.set(0.0f, 1.0f, 0.0f, 0.0f);
stack.leave();
return out;
}
float s = (float)Math.sqrt((1.0f + d) * 2.0f);
float rs = 1.0f / s;
out.set(c.x * rs, c.y * rs, c.z * rs, s * 0.5f);
stack.leave();
return out;
}
示例2: getPlaneEquation
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public void getPlaneEquation(Quaternion plane, int i) {
Stack stack = Stack.enter();
Vector3 halfExtents = getHalfExtentsWithoutMargin(stack.allocVector3());
switch (i) {
case 0:
plane.set(1f, 0f, 0f, -halfExtents.x);
break;
case 1:
plane.set(-1f, 0f, 0f, -halfExtents.x);
break;
case 2:
plane.set(0f, 1f, 0f, -halfExtents.y);
break;
case 3:
plane.set(0f, -1f, 0f, -halfExtents.y);
break;
case 4:
plane.set(0f, 0f, 1f, -halfExtents.z);
break;
case 5:
plane.set(0f, 0f, -1f, -halfExtents.z);
break;
default:
assert (false);
}
stack.leave();
}
示例3: mul
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public static void mul (Quaternion q, Vector3 w) {
float rx = q.w * w.x + q.y * w.z - q.z * w.y;
float ry = q.w * w.y + q.z * w.x - q.x * w.z;
float rz = q.w * w.z + q.x * w.y - q.y * w.x;
float rw = -q.x * w.x - q.y * w.y - q.z * w.z;
q.set(rx, ry, rz, rw);
}
示例4: buildTriPlane
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public void buildTriPlane (Quaternion plane) {
Stack stack = Stack.enter();
Vector3 tmp1 = stack.allocVector3();
Vector3 tmp2 = stack.allocVector3();
Vector3 normal = stack.allocVector3();
tmp1.set(vertices1[1]).sub(vertices1[0]);
tmp2.set(vertices1[2]).sub(vertices1[0]);
normal.set(tmp1).crs(tmp2);
normal.nor();
plane.set(normal.x, normal.y, normal.z, vertices1[0].dot(normal));
stack.leave();
}
示例5: edge_plane
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
/** Calc a plane from a triangle edge an a normal. */
public static void edge_plane (Vector3 e1, Vector3 e2, Vector3 normal, Quaternion plane) {
Stack stack = Stack.enter();
Vector3 planenormal = stack.allocVector3();
planenormal.set(e2).sub(e1);
planenormal.set(planenormal).crs(normal);
planenormal.nor();
plane.set(planenormal, e2.dot(planenormal));
stack.leave();
}
示例6: get_plane_equation
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public static void get_plane_equation (StaticPlaneShape shape, Quaternion equation) {
Stack stack = Stack.enter();
Vector3 tmp = stack.allocVector3();
equation.set(shape.getPlaneNormal(tmp), 0);
equation.w = shape.getPlaneConstant();
stack.leave();
}
示例7: transform
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public static void transform(OvrQuaternionf sourceQuaternion, Quaternion quaternion) {
float x = sourceQuaternion.x;
float y = sourceQuaternion.y;
float z = sourceQuaternion.z;
float w = sourceQuaternion.w;
quaternion.set(x, y, z, w);
}
示例8: renderEye
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
private void renderEye(Viewport eye, Vector3 eyeOffset) {
Camera camera = eye.getCamera();
Vector3 eyePosition = camera.position;
eyePosition.set(VirtualReality.body.position);
Vector3 headOffset = new Vector3(0, VirtualReality.head.getEyeHeight() / 2f, 0);
headOffset.mul(VirtualReality.body.orientation);
eyePosition.add(headOffset);
Quaternion eyeOrientation = new Quaternion();
eyeOrientation.set(VirtualReality.head.getOrientation());
eyeOrientation.mul(VirtualReality.body.orientation);
eyeOffset.mul(eyeOrientation);
eyePosition.add(eyeOffset);
Vector3 eyeDirection = new Vector3(0, 0, -1);
eyeDirection.mul(eyeOrientation);
Vector3 eyeUp = new Vector3(0, 1, 0);
eyeUp.mul(eyeOrientation);
camera.position.set(eyePosition);
camera.direction.set(eyeDirection);
camera.up.set(eyeUp);
camera.update(true);
for (VirtualRealityRenderListener listener : listeners) {
listener.render(camera);
}
}
示例9: integrateTransform
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
@StaticAlloc
public static void integrateTransform (Transform curTrans, Vector3 linvel, Vector3 angvel, float timeStep,
Transform predictedTransform) {
predictedTransform.origin.x = curTrans.origin.x + timeStep * linvel.x;
predictedTransform.origin.y = curTrans.origin.y + timeStep * linvel.y;
predictedTransform.origin.z = curTrans.origin.z + timeStep * linvel.z;
// //#define QUATERNION_DERIVATIVE
// #ifdef QUATERNION_DERIVATIVE
// btQuaternion predictedOrn = curTrans.getRotation();
// predictedOrn += (angvel * predictedOrn) * (timeStep * btScalar(0.5));
// predictedOrn.nor();
// #else
// Exponential map
// google for "Practical Parameterization of Rotations Using the Exponential Map", F. Sebastian Grassia
Stack stack = Stack.enter();
Vector3 axis = stack.allocVector3();
float fAngle = angvel.len();
// limit the angular motion
if (fAngle * timeStep > ANGULAR_MOTION_THRESHOLD) {
fAngle = ANGULAR_MOTION_THRESHOLD / timeStep;
}
if (fAngle < 0.001f) {
// use Taylor's expansions of sync function
axis.set(angvel).scl(0.5f * timeStep - (timeStep * timeStep * timeStep) * (0.020833333333f) * fAngle * fAngle);
} else {
// sync(fAngle) = sin(c*fAngle)/t
axis.set(angvel).scl((float)Math.sin(0.5f * fAngle * timeStep) / fAngle);
}
Quaternion dorn = stack.allocQuaternion();
dorn.set(axis.x, axis.y, axis.z, (float)Math.cos(fAngle * timeStep * 0.5f));
Quaternion orn0 = curTrans.getRotation(stack.allocQuaternion());
Quaternion predictedOrn = stack.allocQuaternion();
predictedOrn.set(dorn).mul(orn0);
predictedOrn.nor();
// #endif
predictedTransform.setRotation(predictedOrn);
stack.leave();
}
示例10: setRotation
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public static void setRotation (Quaternion q, Vector3 axis, float angle) {
float d = axis.len();
assert (d != 0f);
float s = (float)Math.sin(angle * 0.5f) / d;
q.set(axis.x * s, axis.y * s, axis.z * s, (float)Math.cos(angle * 0.5f));
}
示例11: alloc
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
public Quaternion alloc(Quaternion rotation) {
Quaternion q = allocQuaternion();
q.set(rotation);
return q;
}
示例12: segment_collision
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
/** Find closest points on segments. */
public static void segment_collision (Vector3 vA1, Vector3 vA2, Vector3 vB1, Vector3 vB2, Vector3 vPointA, Vector3 vPointB) {
Stack stack = Stack.enter();
Vector3 AD = stack.allocVector3();
AD.set(vA2).sub(vA1);
Vector3 BD = stack.allocVector3();
BD.set(vB2).sub(vB1);
Vector3 N = stack.allocVector3();
N.set(AD).crs(BD);
float[] tp = new float[] {N.len2()};
Quaternion _M = stack.allocQuaternion();// plane
if (tp[0] < BulletGlobals.SIMD_EPSILON)// ARE PARALELE
{
// project B over A
boolean invert_b_order = false;
_M.x = vB1.dot(AD);
_M.y = vB2.dot(AD);
if (_M.x > _M.y) {
invert_b_order = true;
// BT_SWAP_NUMBERS(_M[0],_M[1]);
_M.x = _M.x + _M.y;
_M.y = _M.x - _M.y;
_M.x = _M.x - _M.y;
}
_M.z = vA1.dot(AD);
_M.w = vA2.dot(AD);
// mid points
N.x = (_M.x + _M.y) * 0.5f;
N.y = (_M.z + _M.w) * 0.5f;
if (N.x < N.y) {
if (_M.y < _M.z) {
vPointB = invert_b_order ? vB1 : vB2;
vPointA = vA1;
} else if (_M.y < _M.w) {
vPointB = invert_b_order ? vB1 : vB2;
closest_point_on_segment(vPointA, vPointB, vA1, vA2);
} else {
vPointA = vA2;
closest_point_on_segment(vPointB, vPointA, vB1, vB2);
}
} else {
if (_M.w < _M.x) {
vPointB = invert_b_order ? vB2 : vB1;
vPointA = vA2;
} else if (_M.w < _M.y) {
vPointA = vA2;
closest_point_on_segment(vPointB, vPointA, vB1, vB2);
} else {
vPointB = invert_b_order ? vB1 : vB2;
closest_point_on_segment(vPointA, vPointB, vA1, vA2);
}
}
stack.leave();
return;
}
N.set(N).crs(BD);
_M.set(N.x, N.y, N.z, vB1.dot(N));
// get point A as the plane collision point
line_plane_collision(_M, AD, vA1, vPointA, tp, 0f, 1f);
/* Closest point on segment */
vPointB.set(vPointA).sub(vB1);
tp[0] = vPointB.dot(BD);
tp[0] /= BD.dot(BD);
tp[0] = CLAMP(tp[0], 0.0f, 1.0f);
BD.scl(tp[0]);
vPointB.set(vB1).add(BD);
stack.leave();
}
示例13: getLocalRotation
import com.badlogic.gdx.math.Quaternion; //导入方法依赖的package包/类
@Override
public Quaternion getLocalRotation(Quaternion out) {
return out.set(localRotation);
}