/////////////////// QUATERNION EXTENSIONS ///////////////////// /* * Vector2 [Quaternion vec].Angle(AuxCoord co, float offset = 0f) / static Vector2 Angle(Quaternion vec, AuxCoord co, float offset = 0f): * Function: Returns a Vector2 with the angle of a particular coordinate plus an offset. * Usefulness: To quickly calculate the angle of a particular coordinate in a Quaternion (adding an offset number if needed). * Based on: [Quaternion].eulerAngles * * Vector2 [Quaternion vec].Angle(string co, float offset = 0f) / static Vector2 Angle(Quaternion vec, string co, float offset = 0f): * Function: Returns a Vector2 with the angle of a particular coordinate plus an offset * (this string must be a valid coordinate {x, y, z}, or else it returns Vector2.zero). * Usefulness: To quickly calculate the angle of a particular coordinate in a Quaternion (adding an offset number if needed), * and quickly writing the coordinate code. * Based on: [Quaternion].eulerAngles * */ public static Vector2 Angle(this Quaternion angle, AuxCoord co, float offset = 0f) { switch (co) { case AuxCoord.x: return((angle.eulerAngles.x + offset).AngleDeg()); case AuxCoord.y: return((angle.eulerAngles.y + offset).AngleDeg()); case AuxCoord.z: return((angle.eulerAngles.z + offset).AngleDeg()); } return(Vector2.zero); }
//UnityEngine Functions: /* * AuxPolygon IntersectionTwoLines<T>(RectTransform a, RectTransform b, AuxCoord co): * Function: Returns an AuxPolygon with the point positions of the intersection of the RectTransform in a 0Z plane * (ignoring Z coordinate) and using the X or Y coordinate of the objects as the main line/angle. * Usefulness: To get the area of two RectTransform inmediately. * Based on: Auxp.i.Intersects <Polygon, Polygon> * Dependences: Auxe, Auxp. * */ public AuxPolygon IntersectionTwoLines(RectTransform a, RectTransform b, AuxCoord co) { if (co == AuxCoord.z) { return(null); } float o = co == AuxCoord.x? 0f : 90f; var awl1 = new AuxWideLine(a.position, a.rotation.Angle(AuxCoord.z, o), co == AuxCoord.x ? a.sizeDelta.y : a.sizeDelta.x); var awl2 = new AuxWideLine(b.position, b.rotation.Angle(AuxCoord.z, o), co == AuxCoord.x ? b.sizeDelta.y : b.sizeDelta.x); return(awl1 * awl2); }
/* * Vector3 [Vector3 vec].Set(float value, AuxCoord c) / static Vector3 Set(Vector3 vec, float value, AuxCoord c): * Function: Returns a new Vector3 with the same data as "vec" but with the coordinate "c" changed to "value". * Usefulness: To quickly create a new Color that only changes one aspect of another one. * * Vector3 [Vector3 vec].Set(float value, string c) / static Vector3 Set(Vector3 vec, float value, string c): * Function: Returns a new Vector3 with the same data as "vec" but with the coordinate "c" changed to "value" * (this string must be a valid coordinate {x, y, z}, or else it changes nothing). * Usefulness: To quickly create a new Vector3 that only changes one aspect of another one, and quickly writing the coordinate code. * */ public static Vector3 Set(this Vector3 vec, float value, AuxCoord c) { return(new Vector3(c == AuxCoord.x ? value : vec.x, c == AuxCoord.y ? value : vec.y, c == AuxCoord.z ? value : vec.z)); }
// (Set): /* * Vector2 [Vector2 vec].Set(float value, AuxCoord c) / static Vector2 Set(Vector2 vec, float value, AuxCoord c): * Function: Returns a new Vector2 with the same data as "vec" but with the coordinate "c" changed to "value". * Usefulness: To quickly create a new Color that only changes one aspect of another one. * * Vector2 [Vector2 vec].Set(float value, string c) / static Vector2 Set(Vector2 vec, float value, string c): * Function: Returns a new Vector2 with the same data as "vec" but with the coordinate "c" changed to "value" * (this string must be a valid coordinate {x, y}, or else it changes nothing). * Usefulness: To quickly create a new Vector2 that only changes one aspect of another one, and quickly writing the coordinate code. * */ public static Vector2 Set(this Vector2 vec, float value, AuxCoord c) { return(new Vector2(c == AuxCoord.x ? value : vec.x, c == AuxCoord.y ? value : vec.y)); }