/// <summary> /// Returns a unit vector created via azimuth and elevation angles relative to the given directional vectors. /// </summary> /// <param name="angles">The set of angles to for the calculation.</param> /// <param name="up">The local positive y direction.</param> /// <param name="forward">The local positive z direction.</param> /// <returns>A unit vector with the given azimuth and elevation angles.</returns> public static Vector3 FromAzimuthAndElevation(Angles.AngleVector3 angles, Vector3 up, Vector3 forward) { Vector3 compoundVec = Vector3.zero; up.Normalize(); forward.Normalize(); // relative x component compoundVec += Mathf.Sin(Mathf.Deg2Rad * angles.azimuth) * Mathf.Cos(Mathf.Deg2Rad * angles.elevation) * Vector3.Cross(up, forward); // relative y component compoundVec += Mathf.Sin(Mathf.Deg2Rad * angles.elevation) * up; // relative z component compoundVec += Mathf.Cos(Mathf.Deg2Rad * angles.azimuth) * Mathf.Cos(Mathf.Deg2Rad * angles.elevation) * forward; return(compoundVec); }
/// <summary> /// Returns a unit vector created via azimuth and elevation angles relative to the given directional vectors. /// </summary> /// <param name="angles">The set of angles to for the calculation.</param> /// <returns>A unit vector with the given azimuth and elevation angles.</returns> public static Vector3 FromAzimuthAndElevation(Angles.AngleVector3 angles) { return(FromAzimuthAndElevation(angles, Vector3.up, Vector3.forward)); }