Matrix4 extractBasis question

Hello!

const xAxis = new THREE.Vector3();
const yAxis = new THREE.Vector3();
const zAxis = new THREE.Vector3();
object.matrixWorld.extractBasis(xAxis, yAxis, zAxis);

const xAxis = new THREE.Vector3(1, 0, 0);
const yAxis = new THREE.Vector3(0, 1, 0);
const zAxis = new THREE.Vector3(0, 0, 1);
const quat = new THREE.Quaternion().setFromRotationMatrix(object.matrixWorld);
xAxis.applyQuaternion(quat);
yAxis.applyQuaternion(quat);
zAxis.applyQuaternion(quat);

According to my understanding, the axis calculated by the two methods should be the same, but I got different results.

1 Like

In some cases, they are the same, but sometimes they are not.
I am very confused about this, what can cause different situations to happen?

One possible reason is when the object is scaled.

just a guess,
had some complex positioning to achieve as well, and the only safe method for me was to
matrix.decompose the object, then use the outputs (so the quaternion in you case).

How different?

I would expect some minor numerical differences, but not much…

@rookie, have you checked that these differences aren’t an abstraction of 0 under eulers constant…?

If a number is followed by e-N this is typically a sign that the number is a numerical representation of a number divided by a power which results in numbers minutely close to 0 but not absolutely 0, this can look confusing in the console because some of those numbers can start with positive numbers, eg… 5.294685e-56

EDIT: a good way to check this is if a value contains “e-” you should be able to practically assume that it’s 0, or a representation thereof…

1 Like