0

I'm trying to rotate an object in the direction of a given angle that I have Theta & Phi values for. How does this apply when using something like

Vector3 rayRotate = new Vector3 (theta, phi, 0);
beamContainer.transform.rotation = Quaternion.Euler(rayRotate);

Should theta & phi be used directly on the X/Y or do I need to be running a Sin/Cos formula on them?

I have been trying all sort of combinations and varions but I can not get beamContainer pointing in the direction and have this aligned with the object that should be pointing that direction,

  • Do you mean theta and phi as in spherical coordinates? – Galandil Feb 17 '18 at 14:00
  • 1
    Without knowing details about unity's quaternion implementation, rotations are realized by multiplying two quaternions. No sin/cos formulae (these are applied implicitly by the framework when you create the quaternion). Mathematically you would have to convert your coordinate vector to a quaternion as well and multiply it by the rotation. But there may be an easier way in Unity (for convenience). It is mostly like with complex numbers if that comparison helps you. – oliver Feb 17 '18 at 14:47

1 Answers1

0

I was able to resolve my issue and rotate the beamContainer in the required direction via:

beamContainer.transform.rotation = Quaternion.Euler(-90 + phi, -theta, 0f);