示例#1
0
        public static         Hex[] Line(Hex a, Hex b)
        {
            int N = a.Distance(b);

            Hex[] results = new Hex[N + 1];

            FractionalHex a_nudge = new FractionalHex(a.Q + 0.000001f, a.R + 0.000001f, a.S - 0.000002f);
            FractionalHex b_nudge = new FractionalHex(b.Q + 0.000001f, b.R + 0.000001f, b.S - 0.000002f);

            float step = 1.0f / Math.Max(N, 1);

            for (int i = 0; i <= N; i++)
            {
                results[i] = a_nudge.Lerp(b_nudge, step * i).Round();
            }

            return(results);
        }
示例#2
0
 public FractionalHex Lerp(FractionalHex b, float t)
 {
     return(new FractionalHex(Q * (1.0f - t) + b.Q * t, R * (1.0f - t) + b.R * t, S * (1.0f - t) + b.S * t));
 }
示例#3
0
 public Hex[] Line(Hex a, Hex b)
 {
     return(FractionalHex.Line(a, b));
 }