SetLookRotation doesn't give back the vectors I threw at it?

Hi, sorry if this has been asked int.Max times before.

I am setting a Quaternion with SetLookRotation(f, u) but the vectors I get back from the transform are different (and by more than a tiny amount too). Can someone please explain what I am missing here?

if (this.tf.forward != this.splineTangent)
{
this.tf.rotation.SetLookRotation(this.splineTangent, this.splineUp);
if (this.tf.forward != this.splineTangent)
{
Debug.Log("df " + (this.tf.forward - this.splineTangent).magnitude);
}
if (this.tf.up != this.splineUp)
{
Debug.Log("du " + (this.tf.up - this.splineUp).magnitude + " tan " + this.splineTangent.magnitude + " up " + this.splineUp.magnitude);
}
}

I see output like:
df 0.1523634
du 0.4578745 tan 1 up 0.99999999

Surely the fwd and up vectors should be unchanged (allowing for numerical errors)?

Thanks.

Okay, clearly this is because the up vector I am supplying is not orthogonal, sorry to bother the group…

I believe your problem is this line:

this.tf.rotation.SetLookRotation(this.splineTangen t, this.splineUp);

tf.rotation is a property returning a struct, which means that your function call is applied to a useless copy of the rotation.

Try if this fixes your problem:

this.tf.rotation = Quaternion.SetLookRotation(this.splineTangen t, this.splineUp);

If this code is in fact JS (impossible to tell from the fragment :P), this may not be true, as Unity does implement some automatic workarounds for the ‘property returning struct’ issue.

Edit:
While orthogonality might explain your problem regarding ‘up’, foward should always match.

You were quite right there too, though I had tried all those variants in my messing around before realising about the lack of orthogonality. Thanks.