我想将我的四元数坐标更改为旋转坐标

I want to change my quaternions coordinate to rotation coordinates

我正在从传感器获取四元数坐标 [x,y,z,w]。我想更改该坐标,以便我可以旋转我的 React VR 应用程序场景来旋转该场景。我需要将四元数坐标更改为旋转坐标。但是这里的旋转并不平滑,平滑的旋转"quaternion coordinate"必须转为旋转

import {VRInstance} from 'react-vr-web';
import scene from 'three.js';
//let us assume x,y,z,w are my coordinate in quaternion formate which I //am taking through web socket
function init(bundle, parent, options) 
{
 //scene=new scene()//three.js

  const vr = new VRInstance(bundle, 'musical_exp_react_vr_pusher', 
 parent, {
    // Add custom options here
    ...options,
  });
  vr.render = function() {
  //but its not working as I took the quaternion coordiate
 //smoothness is not there
 vr.scene.rotationx=x;
 vr.scene.rotationx=y;
 vr.scene.rotationx=z;

 //it is also not working
 vr.scene.quaternion.x=x;
 vr.scene.quaternion.y=y;
 vr.scene.quaternion.z=z;

  // Any custom behavior you want to perform on each frame goes here
  };
  // Begin the animation loop
  vr.start();
  return vr;
 }

 window.ReactVR = {init};

主要问题是我需要从四元数坐标中找到旋转轴坐标。

Quaternions and Euler angles are two separate concepts, and cannot be converted via simple assignment. Depending on the type of Euler angles your framework is using, the conversion algorithm can be a bit complex.

Three.js 在 Euler.setFromQuaternion() 方法中实现此转换。

但是,查看 three.js 的文档,quaternion assignment should work 似乎如您所愿 - 您只需要分配四元数的所有 4 个元素(您的代码缺少 W 元素) .