// just for rotation public Matrix2x2 Inverse() { Vector2 newOne = new Vector2(mLast[1], -mFirst[1]); Vector2 newTwo = new Vector2(-mLast[0], mFirst[0]); float rdet = 1.0f / Det(); Matrix2x2 inv = new Matrix2x2(newOne * rdet, newTwo * rdet); return(inv); }
public static Matrix2x2 CreateMatrix2D(Vector2 from, Vector2 to) { float degree = VectorAngleVector(from, to); Vector2 oneRow; Vector2 twoRow; CreateMatrix2D(degree, out oneRow, out twoRow); Matrix2x2 res = new Matrix2x2(oneRow, twoRow); return(res); }
public static Matrix2x2 CreateMatrix2D(float degree, Vector2 center) { Vector2 oneRow; Vector2 twoRow; CreateMatrix2D(degree, out oneRow, out twoRow); Matrix2x2 res = new Matrix2x2(oneRow, twoRow); res.Translate = center; return(res); }
public static List <Vector2> CalculateCircle(float angle, float r, Vector2 center) { List <Vector2> cir = new List <Vector2>(); Matrix2x2 mat2 = MatrixUtils.CreateMatrix2D(angle, center); mat2.Scale = Vector2.one * r; Vector2 start = new Vector2(0, 1); int count = (int)(360.0f / angle); for (int i = 0; i < count; ++i) { Vector2 next = mat2.Rotate(start); start = next.normalized; cir.Add(start * r + center); } return(cir); }