0

Good eve all!

I'm making simple model editor on WPF for creating cube-head freaks with pixelate skins and want add billboarding to it.

So, what I do

Vector3D unitZ = new Vector3D(0, 0, 1);
Vector3D direction = -this.camera.LookDirection;
double yaw = Vector3D.AngleBetween(unitZ, new Vector3D(0, 0, direction.Z));

and the apply rotation to plane. It works, but only on half, couse AngleBetween function allways returns positive values. So when I rotate parent shape to -45 degrees AngleBetween returns 45 and it annihilate parent rotation. But when I rotate parent on 45 degrees AngleBetween again returns 45 and in result I got 90 degrees rotation.

Any solutions?

And one more thing: please, do not offer any frameworks or toolkits! Thanks.

1 Answers1

0

Well, that's how AngleBetween method works for 3D vectors in WPF. It returns value in the range of [0..180] degrees.

As far as your problem goes, I am not 100% I understand you. The angle between [0, 0, 1] and [0, 0, arbitrary number here] can only give you three different values: :

  • impossible to calculate
  • 180
  • 0
  • -180 if signed is possible.

As I don't really see how you can ever get 45.

Either way, it's possible that you can use Vector.AngleBetween which should preserve the sign. That will work if your rotation is only on one axis, eg one of the components stay the same.

If that does not suit your needs, you should just write what you need: Signed angle between two 3D vectors with same origin within the same plane

Community
  • 1
  • 1
Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78
  • Yeah... I'm solve it. But "solve" will be wrong world. I think first problem was in the AngleBetween method, but then bug gone. I'm even can not say what was wrong so just close this question. And thanks for answer! –  Dec 29 '14 at 08:07