当前位置: 首页>>代码示例>>Java>>正文


Java Quaternion类代码示例

本文整理汇总了Java中org.rajawali3d.math.Quaternion的典型用法代码示例。如果您正苦于以下问题:Java Quaternion类的具体用法?Java Quaternion怎么用?Java Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Quaternion类属于org.rajawali3d.math包,在下文中一共展示了Quaternion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyRotation

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
private void applyRotation()
{
    if (mIsRotating)
    {
        mapToSphere((float) mPrevScreenCoord.getX(), (float) mPrevScreenCoord.getY(), mPrevSphereCoord);
        mapToSphere((float) mCurrScreenCoord.getX(), (float) mCurrScreenCoord.getY(), mCurrSphereCoord);

        Vector3 rotationAxis = mPrevSphereCoord.clone();
        rotationAxis.cross(mCurrSphereCoord);
        rotationAxis.normalize();

        double rotationAngle = Math.acos(Math.min(1, mPrevSphereCoord.dot(mCurrSphereCoord)));
        mCurrentOrientation.fromAngleAxis(rotationAxis, MathUtil.radiansToDegrees(rotationAngle));
        mCurrentOrientation.normalize();

        Quaternion q = new Quaternion(mStartOrientation);
        q.multiply(mCurrentOrientation);

        mEmpty.setOrientation(q);
    }
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:22,代码来源:ArcballCamera.java

示例2: ASpiral3D

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Constructs a {@link ArchimedeanSpiral3D} with the specified parameters.
 *
 * @param density  {@code double} Factor which determines how tightly the spiral is curled.
 * @param start    {@link Vector3} The point where the spiral should start from.
 * @param normal   {@link Vector3} The normal vector of the plane the spiral is in. This is assumed to be
 *                 orthogonal to the vector formed from the start to the origin.
 * @param spiralIn {@code boolean} True if the spiral should move from the staring point in. False to move from starting point out.
 */
public ASpiral3D(double density, Vector3 start, Vector3 normal, boolean spiralIn) {
    // Store the provided initial conditions
    mSpiralIn = spiralIn;
    mDensity = density;
    mStart = Vector3.subtractAndCreate(start, Vector3.ZERO);
    mUp = normal.clone();

    // Calculate the remaining conditions
    mCalculateTangents = false;

    // Create the initial tangent vector
    mCurrentTangent = Vector3.crossAndCreate(mStart, mUp);
    // The initial rotation is 0 radians about the up axis
    mRotation = new Quaternion(mUp, 0);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:25,代码来源:ASpiral3D.java

示例3: matrixToTangoPose

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Converts a transform in Matrix4 format to TangoPoseData.
 */
public static TangoPoseData matrixToTangoPose(Matrix4 transform) {
    // Get translation and rotation components from the transformation matrix.
    Vector3 p = transform.getTranslation();
    Quaternion q = new Quaternion();
    q.fromMatrix(transform);

    TangoPoseData tangoPose = new TangoPoseData();
    double[] t = tangoPose.translation = new double[3];
    t[0] = p.x;
    t[1] = p.y;
    t[2] = p.z;
    double[] r = tangoPose.rotation = new double[4];
    r[0] = q.x;
    r[1] = q.y;
    r[2] = q.z;
    r[3] = q.w;

    return tangoPose;
}
 
开发者ID:inovex,项目名称:tango-ar-navigation-example,代码行数:23,代码来源:ScenePoseCalculator.java

示例4: matrixToTangoPose

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Converts a transform in Matrix4 format to TangoPoseData.
 */
public static TangoPoseData matrixToTangoPose(Matrix4 transform) {
    // Get translation and rotation components from the transformation matrix
    Vector3 p = transform.getTranslation();
    Quaternion q = new Quaternion();
    q.fromMatrix(transform);
    // NOTE: Rajawali Quaternions use a left-hand rotation around the axis convention
    q.conjugate();

    TangoPoseData tangoPose = new TangoPoseData();
    double[] t = tangoPose.translation = new double[3];
    t[0] = p.x;
    t[1] = p.y;
    t[2] = p.z;
    double[] r = tangoPose.rotation = new double[4];
    r[0] = q.x;
    r[1] = q.y;
    r[2] = q.z;
    r[3] = q.w;

    return tangoPose;
}
 
开发者ID:kupoko,项目名称:Tiresias,代码行数:25,代码来源:ScenePoseCalcuator.java

示例5: updateRenderCameraPose

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Update the scene camera based on the provided pose in Tango start of service frame.
 * The camera pose should match the pose of the camera color at the time the last rendered RGB
 * frame, which can be retrieved with this.getTimestamp();
 * <p/>
 * NOTE: This must be called from the OpenGL render thread - it is not thread safe.
 */
public void updateRenderCameraPose(TangoPoseData cameraPose) {
    float[] rotation = cameraPose.getRotationAsFloats();
    float[] translation = cameraPose.getTranslationAsFloats();
    Quaternion quaternion = new Quaternion(rotation[3], rotation[0], rotation[1], rotation[2]);
    // Conjugating the Quaternion is need because Rajawali uses left handed convention for
    // quaternions.
    getCurrentCamera().setRotation(quaternion.conjugate());
    getCurrentCamera().setPosition(translation[0], translation[1], translation[2]);
}
 
开发者ID:tdb-alcorn,项目名称:defect-party,代码行数:17,代码来源:FloorplanRenderer.java

示例6: addWallMeasurement

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Add a new WallMeasurement.
 * A new cube will be added at the plane position and orientation to represent the measurement.
 */
public synchronized void addWallMeasurement(WallMeasurement wallMeasurement) {
    float[] openGlTWall = wallMeasurement.getPlaneTransform();
    Matrix4 openGlTWallMatrix = new Matrix4(openGlTWall);
    mNewPoseList.add(new Pose(openGlTWallMatrix.getTranslation(),
            new Quaternion().fromMatrix(openGlTWallMatrix).conjugate()));
    mObjectPoseUpdated = true;
}
 
开发者ID:tdb-alcorn,项目名称:defect-party,代码行数:12,代码来源:FloorplanRenderer.java

示例7: transform

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Transforms this {@link Vector3} using the given {@link Quaternion}.
 *
 * @param quat {@link Vector3} The {@link Vector3} to transform.
 *
 * @return {@link Vector3} The transformed {@link Vector3}. This is the same as the parameter quat.
 */
public Vector3 transform(Quaternion quat) {
    Quaternion tmp = new Quaternion(quat);
    Quaternion tmp2 = new Quaternion(0, x, y, z);
    tmp.conjugate();
    tmp.multiplyLeft(tmp2.multiplyLeft(quat));

    return setAll(tmp.x, tmp.y, tmp.z);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:16,代码来源:Vector3.java

示例8: getRotationTo

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * Creates a {@link Quaternion} which represents the rotation from a this {@link Vector3}
 * to the provided {@link Vector3}. Adapted from OGRE 3D engine.
 *
 * @param direction {@link Vector3} The direction to rotate to.
 *
 * @return {@link Quaternion} The {@link Quaternion} representing the rotation.
 * @see http://ogre.sourcearchive.com/documentation/1.4.5/classOgre_1_1Vector3_eeef4472ad0c4d5f34a038a9f2faa819.html#eeef4472ad0c4d5f34a038a9f2faa819
 */
public Quaternion getRotationTo(Vector3 direction) {
    // Based on Stan Melax's article in Game Programming Gems
    Quaternion q = new Quaternion();
    // Copy, since cannot modify local
    Vector3 v0 = this;
    Vector3 v1 = direction;
    v0.normalize();
    v1.normalize();

    double d = Vector3.dot(v0, v1);
    // If dot == 1, vectors are the same
    if (d >= 1.0f) {
        q.identity();
    }
    if (d < 0.000001 - 1.0) {
        // Generate an axis
        Vector3 axis = Vector3.crossAndCreate(Vector3.getAxisVector(Axis.X), this);
        if (axis.length() == 0) // pick another if colinear
            axis = Vector3.crossAndCreate(Vector3.getAxisVector(Axis.Y), this);
        axis.normalize();
        q.fromAngleAxis(axis, MathUtil.radiansToDegrees(MathUtil.PI));
    } else {
        double s = Math.sqrt((1 + d) * 2);
        double invs = 1 / s;

        Vector3 c = Vector3.crossAndCreate(v0, v1);

        q.x = c.x * invs;
        q.y = c.y * invs;
        q.z = c.z * invs;
        q.w = s * 0.5;
        q.normalize();
    }
    return q;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:45,代码来源:Vector3.java

示例9: RotateAnimation3D

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
public RotateAnimation3D(double xRotate, double yRotate, double zRotate) {
	super();

	mQuat = Quaternion.getIdentity();
	mQuatFrom = new Quaternion();

	mRotateX = xRotate;
	mRotateY = yRotate;
	mRotateZ = zRotate;

	mQuat.multiply(new Quaternion().fromAngleAxis(Vector3.getAxisVector(Axis.Y), yRotate));
	mQuat.multiply(new Quaternion().fromAngleAxis(Vector3.getAxisVector(Axis.Z), zRotate));
	mQuat.multiply(new Quaternion().fromAngleAxis(Vector3.getAxisVector(Axis.X), xRotate));
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:15,代码来源:RotateAnimation3D.java

示例10: RotateOnAxisAnimation

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
protected RotateOnAxisAnimation(Vector3 axis) {
	super();

	mRotationAxis = axis;
	mQuat = new Quaternion();
	mQuatFrom = new Quaternion();
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:8,代码来源:RotateOnAxisAnimation.java

示例11: SlerpAnimation3D

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
public SlerpAnimation3D(Vector3 from, Vector3 to) {
	super();
	mFrom = quaternionFromVector(from.clone());
	mTo = quaternionFromVector(to.clone());
	mTmpVec = new Vector3();
	mTmpQuatVector = new Vector3();
	mTmpQuat = new Quaternion();
	mDistance = from.length();
	mRotationMatrix = new double[16];
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:11,代码来源:SlerpAnimation3D.java

示例12: quaternionFromVector

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
protected Quaternion quaternionFromVector(Vector3 vec) {
	vec.normalize();
	final double angle = MathUtil.radiansToDegrees(Math.acos(Vector3.dot(mForwardVec, vec)));
	final Quaternion q = new Quaternion();
	q.fromAngleAxis(mTmpQuatVector.crossAndSet(mForwardVec, vec), angle);
	return q;
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:8,代码来源:SlerpAnimation3D.java

示例13: initialize

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
private void initialize() {
    mStartFOV = mFieldOfView;
    mLookAtEnabled = true;
    setLookAt(0, 0, 0);
    mEmpty = new Object3D();
    mScratchMatrix = new Matrix4();
    mScratchVector = new Vector3();
    mCameraStartPos = new Vector3();
    mPrevSphereCoord = new Vector3();
    mCurrSphereCoord = new Vector3();
    mPrevScreenCoord = new Vector2();
    mCurrScreenCoord = new Vector2();
    mStartOrientation = new Quaternion();
    mCurrentOrientation = new Quaternion();
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:16,代码来源:ArcballCamera.java

示例14: Camera

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
 * End guarded members
 */
	
public Camera() {
	super();
	mLocalOrientation = Quaternion.getIdentity();
	mIsCamera = true;
	mFrustum = new Frustum();
	mFrustumCorners = new Vector3[8];
       for(int i=0; i<8; i++) {
           mFrustumCorners[i] = new Vector3();
       }
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:15,代码来源:Camera.java

示例15: ATransformable3D

import org.rajawali3d.math.Quaternion; //导入依赖的package包/类
/**
    * Default constructor for {@link ATransformable3D}.
    */
public ATransformable3D() {
       mLookAt = new Vector3(0);
       mLookAtEnabled = false;
	mPosition = new Vector3();
	mScale = new Vector3(1, 1, 1);
	mOrientation = new Quaternion();
	mTmpOrientation = new Quaternion();
       mUpAxis = new Vector3(WorldParameters.UP_AXIS);
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:13,代码来源:ATransformable3D.java


注:本文中的org.rajawali3d.math.Quaternion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。