// The set the values for the Translate method.
        public R1Direction <IDirection> Translate(int coordinateSystemDirection, float amount)
        {
            float finalX = StartingPoint.GetAxisAt(0);
            float originalXCoordinate = finalX;


            switch (coordinateSystemDirection)
            {
            case 1:
                finalX -= Math.Abs(amount);

                break;

            default:
                finalX += Math.Abs(amount);
                break;
            }

            Point point = new R1Point(StartingPoint).Position;

            point.SetAxisAt(0, finalX);
            StartingPoint = point;

            R1Direction <IDirection> translatedDirection = (R1Direction <IDirection>)Clone();

            point.SetAxisAt(0, originalXCoordinate);
            StartingPoint = point;

            return(translatedDirection);
        }
        // Only reflect about the origin. That is axisIndex 1.
        public R1Direction <IDirection> ReflectAboutAxis(int axisIndex)
        {
            int   originalDirection = direction.MyDirection;
            Point originalPoint     = StartingPoint;

            StartingPoint = new R1Point(-1 * StartingPoint.GetAxisAt(0)).Position;


            if (axisIndex == 1)
            {
                if (direction.MyDirection == 1)
                {
                    direction.MyDirection = 2;
                }
                else if (direction.MyDirection == 2)
                {
                    direction.MyDirection = 1;
                }
            }

            R1Direction <IDirection> reflectedDirection = (R1Direction <IDirection>)Clone();

            direction.MyDirection = originalDirection;
            StartingPoint         = originalPoint;

            return(reflectedDirection);
        }
        public R1CDirection()
            : base()
        {
            circularDirection = new CircularDirection <R1CDirection, R1Point>();
            directionHelper   = new R1Direction <R1CDirection>();

            InitializeAttributes();
        }
        public R1CDirection(R1Direction <R1CDirection> directionHelper)
        {
            this.directionHelper = directionHelper;

            circularDirection = new CircularDirection <R1CDirection, R1Point>(
                CreateCanSwitchList(), true, 1);

            InitializeAttributes();
        }
        // Move direction.
        // Change the starting position on a direction.
        public override R1CircularDirection translate(int coordinateSystemDirection, float amount)
        {
            float finalX = StartingPoint.GetAxisAt(0);

            R1Direction <R1CircularDirection, CircularLinkedList <R1Point>, CircularDirection <R1CircularDirection, R1Point> > .Translate(coordinateSystemDirection, amount, ref finalX);

            return(new R1CircularDirection(new R1Point(finalX),
                                           Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, Duration, numberOfRotations));
        }
        public R1CDirection(R1Point startingPoint, int direction, float directionLength,
                            float directionDivisor, List <float> speedList, List <bool> canSwitchList,
                            int numberOfRepeatations, bool canSwitch, float speed)
        {
            circularDirection = new CircularDirection <R1CDirection, R1Point>(
                canSwitchList, canSwitch, numberOfRepeatations);

            directionHelper = new R1Direction <R1CDirection>(startingPoint, direction,
                                                             directionLength, directionDivisor, speedList, speed);


            InitializeAttributes();
        }
        // Only reflect about the origin. That is axisIndex 1.
        public override R1CircularDirection ReflectAboutAxis(int axisIndex)
        {
            R1Direction <R1CircularDirection, CircularLinkedList <R1Point>, CircularDirection <R1CircularDirection, R1Point> > .ReflectAboutAxis(axisIndex, ref direction);

            if (axisIndex == 0)
            {
                return(new R1CircularDirection(new R1Point(StartingPoint), (Direction == 1)?2:1, SharedDirection.DirectionLength, SharedDirection.Divisor, Duration, numberOfRotations));
            }
            else
            {
                return(new R1CircularDirection(new R1Point(StartingPoint), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, Duration, numberOfRotations));
            }
        }
        // Helper method for comparing two objects of this class.
        public int CompareTo(R1Direction <IDirection> other)
        {
            int result = 0;

            if (direction.SharedDirection.GetDirectionLength() < other.Direction.SharedDirection.GetDirectionLength())
            {
                result = -1;
            }

            else if (direction.SharedDirection.GetDirectionLength() > other.Direction.SharedDirection.GetDirectionLength())
            {
                result = 1;
            }

            else
            {
                if (direction.SharedDirection.Divisor < other.Direction.SharedDirection.Divisor)
                {
                    result = -1;
                }

                else if (direction.SharedDirection.Divisor > other.Direction.SharedDirection.Divisor)
                {
                    result = 1;
                }

                else
                {
                    if (direction.MyDirection < other.Direction.MyDirection)
                    {
                        result = -1;
                    }

                    else if (direction.MyDirection > other.Direction.MyDirection)
                    {
                        result = 1;
                    }
                }
            }

            return(result);
        }
 // Checkes whether or not points making up a direction have a correct dimension.
 public override bool IsPointDimensionCorrect()
 {
     return(R1Direction <R1CircularDirection, CircularLinkedList <R1Point>, CircularDirection <R1CircularDirection, R1Point> > .IsPointDimensionCorrect(StartingPoint));
 }
 // Will always return  true for a one dimensional direction.
 public override bool IsDirectionDimensionCorrect()
 {
     return(R1Direction <R1CircularDirection, CircularLinkedList <R1Point>, CircularDirection <R1CircularDirection, R1Point> > .IsDirectionDimensionCorrect(Dimension));;
 }
Пример #11
0
        // Only reflect about the origin. That is axisIndex 1.
        public override R1NonCircularDirection ReflectAboutAxis(int axisIndex)
        {
            R1Direction <R1NonCircularDirection, DoubleLinkedList <R1Point>, NonCircularDirection <R1NonCircularDirection, R1Point> > .ReflectAboutAxis(axisIndex, ref direction);

            return(new R1NonCircularDirection(new R1Point(StartingPoint), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, Duration));
        }