Hello,
I apologize if I am missing something blatantly obvious here, but I am having a hard time understanding values I am getting from a piece of code I have written that is making use of this function even after reading related issues to it.
here is some trivial example code illustrating the crux of what I am trying to do:
let itemPosition = vec3.fromValues(0.0, 0.0, 10.0);
let itemTarget = vec3.fromValues(0.0, 0.0, 0.0);
let itemUp = vec3.fromValues(0.0, 1.0, 0.0);
let targetToMatrix = mat4.create();
mat4.targetTo(targetToMatrix, itemPosition, itemTarget, itemUp);
let rotationQuat = quat.create();
mat4.getRotation(rotationQuat, targetToMatrix);
let forwardVector = vec3.fromValues(0.0, 0.0, 1.0);
vec3.transformQuat(forwardVector, forwardVector, rotationQuat);
At this point when inspecting the values of forwardVector I am seeing: [0, 0, 1]. I would expect this to have been [0, 0, -1] . In all of the other cases I try, the resulting forward seems to be the negated vector of what I would expect as well.
I assume that I am missing something fundamental about the math here, but I would appreciate it if someone could shed some light on how i could use this function correctly to compute a forward vector from the object i am trying to rotate to its target.
Hello, I apologize if I am missing something blatantly obvious here, but I am having a hard time understanding values I am getting from a piece of code I have written that is making use of this function even after reading related issues to it.
here is some trivial example code illustrating the crux of what I am trying to do:
At this point when inspecting the values of
forwardVector
I am seeing:[0, 0, 1]
. I would expect this to have been[0, 0, -1]
. In all of the other cases I try, the resulting forward seems to be the negated vector of what I would expect as well.I assume that I am missing something fundamental about the math here, but I would appreciate it if someone could shed some light on how i could use this function correctly to compute a forward vector from the object i am trying to rotate to its target.
I really appreciate your time! Matthew