示例#1
0
 public AvidModelWindow(AvidDirection direction, AvidRing ring, bool abovePlane)
     : base(direction, ring, abovePlane)
 {
     AdjacentWindows = new List <AvidModelLink>();
     DiagonalWindows = new List <AvidModelLink>();
     ClearOperationalData();
 }
示例#2
0
        /// <summary>
        /// Creates a closed circle of windows connected by links.
        /// </summary>
        private static AvidModelWindow[] BuildFullRing(AvidModel model, AvidRing ring, bool abovePlane)
        {
            AvidModelWindow firstWindow    = null;
            AvidModelWindow previousWindow = null;

            var result = new AvidModelWindow[12];

            for (int i = 1; i <= 12; i++)
            {
                var newWindow = new AvidModelWindow((AvidDirection)i, ring, abovePlane);
                result[i - 1] = newWindow;

                if (firstWindow == null)
                {
                    firstWindow = newWindow;
                }

                if (previousWindow != null)
                {
                    model.Links.Add(new AvidModelLink(newWindow, previousWindow, 2, false, false));
                }
                previousWindow = newWindow;
                model.Windows.Add(newWindow);
            }
            //Connect first and last windows closing the circle.
            model.Links.Add(new AvidModelLink(firstWindow, previousWindow, 2, false, false));

            return(result);
        }
示例#3
0
        /// <summary>
        /// Creates a closed circle of windows connected by links.
        /// </summary>
        private static AvidModelWindow[] BuildFullRing(AvidModel model, AvidRing ring, bool abovePlane)
        {
            AvidModelWindow firstWindow = null;
            AvidModelWindow previousWindow = null;

            var result = new AvidModelWindow[12];

            for (int i = 1; i <= 12; i++)
            {
                var newWindow = new AvidModelWindow((AvidDirection)i, ring, abovePlane);
                result[i - 1] = newWindow;

                if (firstWindow == null)
                {
                    firstWindow = newWindow;
                }

                if (previousWindow != null)
                {
                    model.Links.Add(new AvidModelLink(newWindow, previousWindow, 2, false, false));
                }
                previousWindow = newWindow;
                model.Windows.Add(newWindow);
            }
            //Connect first and last windows closing the circle.
            model.Links.Add(new AvidModelLink(firstWindow, previousWindow, 2, false, false));

            return result;
        }
        public static string AvidRingToNumericFormat(AvidRing ring, bool isAbovePlain)
        {
            char notationSymbol = isAbovePlain ? '+' : '-';

            switch (ring)
            {
                case AvidRing.Blue:
                    return new string(notationSymbol, 1);
                case AvidRing.Green:
                    return new string(notationSymbol, 2);
                case AvidRing.Magenta:
                    return new string(notationSymbol, 3);
                default:
                    return string.Empty;
            }
        }
        public static string AvidRingToNumericFormat(AvidRing ring, bool isAbovePlain)
        {
            char notationSymbol = isAbovePlain ? '+' : '-';

            switch (ring)
            {
            case AvidRing.Blue:
                return(new string(notationSymbol, 1));

            case AvidRing.Green:
                return(new string(notationSymbol, 2));

            case AvidRing.Magenta:
                return(new string(notationSymbol, 3));

            default:
                return(string.Empty);
            }
        }
示例#6
0
        private AvidDirection CalculateDirection(HexVector vector, AvidRing ring)
        {
            if (ring == AvidRing.Magenta)
            {
                return AvidDirection.Undefined;
            }

            if (vector.PlanarProjection == 0)
            {
                throw new ArithmeticException("The ring is not magenta, but planar projection is zero.");
            }

            if (vector.PrimaryComponent.Direction == vector.SecondaryComponent.Direction && vector.SecondaryComponent.Magnitude != 0)
            {
                throw new ArithmeticException("Primary and secondary vectors are both positive but are in the same direction.");
            }

            int primaryMagnitude = vector.PrimaryComponent.Magnitude;
            int secondaryMagnitude = vector.SecondaryComponent.Magnitude;

            if (primaryMagnitude < secondaryMagnitude)
            {
                throw new ArithmeticException("Secondary vector component should not be greater than the primary.");
            }

            if (IsSeeingThroughHexEdge(primaryMagnitude, secondaryMagnitude))
            {
                return (AvidDirection)(((byte)vector.PrimaryComponent.Direction) * 2 - 1);
            }

            if ((vector.PrimaryComponent.Direction == HexAxis.A && vector.SecondaryComponent.Direction == HexAxis.F) ||
                (vector.PrimaryComponent.Direction == HexAxis.F && vector.SecondaryComponent.Direction == HexAxis.A))
            {
                return AvidDirection.FA;
            }

            return (AvidDirection)(((byte)vector.PrimaryComponent.Direction) + ((byte)vector.SecondaryComponent.Direction) - 1);
        }
示例#7
0
        private AvidDirection CalculateDirection(HexVector vector, AvidRing ring)
        {
            if (ring == AvidRing.Magenta)
            {
                return(AvidDirection.Undefined);
            }

            if (vector.PlanarProjection == 0)
            {
                throw new ArithmeticException("The ring is not magenta, but planar projection is zero.");
            }

            if (vector.PrimaryComponent.Direction == vector.SecondaryComponent.Direction && vector.SecondaryComponent.Magnitude != 0)
            {
                throw new ArithmeticException("Primary and secondary vectors are both positive but are in the same direction.");
            }

            int primaryMagnitude   = vector.PrimaryComponent.Magnitude;
            int secondaryMagnitude = vector.SecondaryComponent.Magnitude;

            if (primaryMagnitude < secondaryMagnitude)
            {
                throw new ArithmeticException("Secondary vector component should not be greater than the primary.");
            }

            if (IsSeeingThroughHexEdge(primaryMagnitude, secondaryMagnitude))
            {
                return((AvidDirection)(((byte)vector.PrimaryComponent.Direction) * 2 - 1));
            }

            if ((vector.PrimaryComponent.Direction == HexAxis.A && vector.SecondaryComponent.Direction == HexAxis.F) ||
                (vector.PrimaryComponent.Direction == HexAxis.F && vector.SecondaryComponent.Direction == HexAxis.A))
            {
                return(AvidDirection.FA);
            }

            return((AvidDirection)(((byte)vector.PrimaryComponent.Direction) + ((byte)vector.SecondaryComponent.Direction) - 1));
        }
示例#8
0
 public double RingToLatitude(AvidRing ring)
 {
     return(Math.PI * ((byte)ring - 1) / 6d);
 }
示例#9
0
 public AvidRingViewModel(AvidRing ring, bool isAbovePlane)
 {
     _ring         = ring;
     _isAbovePlane = isAbovePlane;
 }
示例#10
0
 public AvidVector(AvidDirection direction, AvidRing ring, bool abovePlane, int magnitude)
     : base(direction, ring, abovePlane)
 {
     Magnitude = magnitude;
 }
 private int GetAvidRingProjectionNumber(AvidRing ring)
 {
     return 4 - (byte)ring;
 }
示例#12
0
 public static void CheckAvidWindow(AvidWindow window, AvidDirection expectedDirection, AvidRing expectedRing, bool abovePlane)
 {
     window.Direction.Should().Be(expectedDirection);
     window.Ring.Should().Be(expectedRing);
     window.AbovePlane.Should().Be(abovePlane);
 }
示例#13
0
 public AvidRingViewModel(AvidRing ring, bool isAbovePlane)
 {
     _ring = ring;
     _isAbovePlane = isAbovePlane;
 }
示例#14
0
 public AvidWindow(AvidDirection direction, AvidRing ring, bool abovePlane)
 {
     Direction  = direction;
     Ring       = ring;
     AbovePlane = abovePlane || (ring == AvidRing.Ember); //Ember ring is above plane by default.
 }
 private AvidRingViewModel SelectRing(AvidRing ring, bool isAbovePlane)
 {
     return(_rings.Single(rn => rn.Ring == ring && rn.IsAbovePlane == isAbovePlane));
 }
示例#16
0
 public AvidVector(AvidDirection direction, AvidRing ring, bool abovePlane, int magnitude)
     : base(direction, ring, abovePlane)
 {
     Magnitude = magnitude;
 }
示例#17
0
        private void CheckDistance(HexGridCoordinate posA, HexGridCoordinate posB, int distance, AvidRing ring, AvidDirection direction, bool isAbovePlane)
        {
            var result = _calculator.GetDistance(posA, posB);

            result.Magnitude.Should().Be(distance);
            result.Ring.Should().Be(ring);
            result.Direction.Should().Be(direction);
            result.AbovePlane.Should().Be(isAbovePlane);
        }
 private void CheckDistance(HexGridCoordinate posA, HexGridCoordinate posB, int distance, AvidRing ring, AvidDirection direction, bool isAbovePlane)
 {
     var result = _calculator.GetDistance(posA, posB);
     result.Magnitude.Should().Be(distance);
     result.Ring.Should().Be(ring);
     result.Direction.Should().Be(direction);
     result.AbovePlane.Should().Be(isAbovePlane);
 }
示例#19
0
 private int GetAvidRingProjectionNumber(AvidRing ring)
 {
     return(4 - (byte)ring);
 }
示例#20
0
 public double RingToLatitude(AvidRing ring)
 {
     return Math.PI * ((byte)ring - 1) / 6d;
 }