using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; namespace Bitsplash.Vector { class CommonVectors { public static List mTmpList = new List(); public static List mTmpSmoothList = new List(); public static Vector2 LineInsersection(Vector2 a1,Vector2 a2,Vector2 b1,Vector2 b2) { float A1 = a2.y - a1.y; float B1 = a1.x - a2.x; float C1 = A1 * a1.x + B1 * a1.y; float A2 = b2.y - b1.y; float B2 = b1.x - b2.x; float C2 = A2 * b1.x + B2 * b1.y; float delta = A1 * B2 - A2 * B1; float x = (B2 * C1 - B1 * C2) / delta; float y = (A1 * C2 - A2 * C1) / delta; return new Vector2(x, y); } static Vector2 Orthogonal(Vector2 v) { return new Vector2(v.y, -v.x); } static Vector2 FromPolar(float angle,float radius) { return new Vector2(Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius); } public static Vector2 InterpolateUV(Vector2 v,Vector2 min,Vector2 size) { return new Vector2((v.x - min.x) / size.x, (v.y - min.y) / size.y); } public static void NPolygon(int edgeCount,float radius,float alternateRadius,List res) { float startAngle = 90 - (180f / (float)edgeCount); for(int i=0; i polygon,float offset,float segments, List res) { for(int i=0; i