You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if I'm using correctly or there is some aprox bug.
Funciton works for rest of angles(vectors are in XZ plane), but when need to rotate from x=-0.9999999 to x=0.9999999 (z same in both 4.222,y=0) rotation gives me 180 rotation around Z instead of Y.
`function orthogonal(v) {
var x = Math.abs(v.x);
var y = Math.abs(v.y);
var z = Math.abs(v.z);
var other = x < y ? ( x < z ? pc.Vec3.RIGHT : pc.Vec3.FORWARD ) : ( y < z ? pc.Vec3.UP : pc.Vec3.FORWARD );
return new pc.Vec3().cross(v, other);
}
pc.Vec3.prototype.orthogonal = function() {
return orthogonal(this);
};
function fromToRotation(v1, v2, q) {
var kct = v1.dot(v2);
q = q || Q();
if (kct <= -0.999) {
q.w = 0;
var v = orthogonal(v1).normalize();
q.x = v.x;
q.y = v.y;
q.z = v.z;
return q;
}
//var half = V(v1).add(v2).scale(0.5);
//
var half = new pc.Vec3().copy(v1).add(v2).scale(0.5);
q.w = v1.dot(half);
var cross = new pc.Vec3().cross(v1, half);
q.x = cross.x;
q.y = cross.y;
q.z = cross.z;
return q.normalize();
}`
The text was updated successfully, but these errors were encountered:
Not sure if I'm using correctly or there is some aprox bug.
Funciton works for rest of angles(vectors are in XZ plane), but when need to rotate from x=-0.9999999 to x=0.9999999 (z same in both 4.222,y=0) rotation gives me 180 rotation around Z instead of Y.
`function orthogonal(v) {
}
pc.Vec3.prototype.orthogonal = function() {
};
function fromToRotation(v1, v2, q) {
}`
The text was updated successfully, but these errors were encountered: