# Quaternion three.js

Hi everyone

I’m newbie in three js and I’m working on website using three js as 3d model. This 3d model has input from database. The data obtained from 9 degree of freedom sensor (x, y, z) in mysql. Then those data converted to pitch yaw roll using quaternion. The object have to rotate based on pitch yaw roll. My question is can three js make rotation based on roll pitch value from quaternion? I’m using blender json as 3d object.

Sounds like you have euler angles when you talk about yaw, pitch and roll. Maybe you are looking for Quaternion.setFromEuler()?

Euler angles cause gimbal lock in rotation. So i can’t use euler angle. Quaternion is algebra. Can I implement pure algebra to three js?

I’m not sure I understand this question. Can you please elaborate a bit?

Can i implement quaternion from mysql which obtained from sensor data using quaternion into roll pitch yaw for object rotation?

Can you post some sample data of your database?

sorry for late reply, here’s my sample data
ax | ay | az | gx |gy |gz | mx |my | mz |
0.007980|0.006246|0.989418|0.001092|0.001923|0.012956|0.464334|0.317907 |1.253211|
0.007780|0.006514|0.976726|0.001165|0.001340|0.013454|0.434578|0.313476 |1.253345|
0.006256|0.003467|0.938771|0.003172|0.002637|0.013349|0.432390|0.356790 |1.345788|
0.006531|0.004456|0.945676|0.002234|0.001365|0.011258|0.485780|0.356791 |1.345793|
0.006536|0.004461|0.945681|0.002239|0.001370|0.011263|0.485785|0.356796 |1.345798|

TBH, I don’t understand these data. Are `ax`, `ay` and `az` supposed to be euler angles? What is the unit of these data?

1 Like

Those are sensor data from accelerometer, gyroscope and magnetometer. ax, ay, az are from acclerometer. gx, gy, gz are from gyroscope. mx, my, mz are from magnetometer. Those data (from mysql) have to calculate with quaternion to get roll pitch yaw values and rotate the object with quaternion

There is no built-in way in `three.js` to transform data from a accelerometer, gyroscope and magnetometer to an orientation expressed as a quaternion.

I’m afraid you have to google this topic (something like “accelerometer, gyroscope to orientation”) and implement a solution by yourself.

In any event, you did not say in which units are your data. Is it m/s2 or maybe degrees/s?

1 Like