Пример #1
0
        public int Manhattan(V2I v)
        {
            var disX = v.Col - Col;
            var disY = v.Row - Row;

            return((disX < 0 ? -disX : disX) + (disY < 0 ? -disY : disY));
        }
Пример #2
0
        double DistanceFromPointToLine(V2I point, V2I pointA, V2I pointB)
        {
            var v1   = pointB - pointA;
            var v2   = point - pointA;
            int dist = v1.Cross(v2) / v1.magnitude;

            return(UnityEngine.Mathf.Abs(dist));
        }
Пример #3
0
 public int Cross(V2I v)
 {
     return(x * v.y - y * v.x);
 }
Пример #4
0
 public int Dot(V2I v)
 {
     return(x * v.x + y * v.y);
 }
Пример #5
0
 public int Cross(V2I v)
 {
     return(Col * v.Row - Row * v.Col);
 }
Пример #6
0
 public int Dot(V2I v)
 {
     return(Col * v.Col + Row * v.Row);
 }