internal double calc360Angle(DirectionX xDir, DirectionY yDir, double theta)
        {
            double angle;

            if (xDir == DirectionX.East)
            {
                angle = 90 - theta;   // North or south since eastSouth = neg Tan theta
                if (angle < 0)
                {
                    angle += 360;
                }
            }
            else
            {
                if (yDir == DirectionY.North)
                {
                    angle = 270 + theta;
                }
                else
                {
                    angle = 270 - theta;    // South
                }
            }
            return(angle);
        }
Exemplo n.º 2
0
 internal void Read(EndianBinaryReader reader)
 {
     AnchorZ.Read(reader);
     PositionZ.Read(reader);
     DirectionX.Read(reader);
     DirectionY.Read(reader);
     DirectionZ.Read(reader);
     RotationX.Read(reader);
     RotationY.Read(reader);
     ScaleZ.Read(reader);
 }
Exemplo n.º 3
0
 internal void Write(EndianBinaryWriter writer)
 {
     AnchorZ.Write(writer);
     PositionZ.Write(writer);
     DirectionX.Write(writer);
     DirectionY.Write(writer);
     DirectionZ.Write(writer);
     RotationX.Write(writer);
     RotationY.Write(writer);
     ScaleZ.Write(writer);
 }
Exemplo n.º 4
0
    //<summary>X字4方向をそれぞれ単位ベクトルに変換</summary>
    static public Vector2 convertToVector(DirectionX aDirection)
    {
        switch (aDirection)
        {
        case DirectionX.leftUp: return((new Vector2(-1, 1)).normalized);

        case DirectionX.leftDown: return((new Vector2(-1, -1)).normalized);

        case DirectionX.rightUp: return((new Vector2(1, 1)).normalized);

        case DirectionX.rightDown: return((new Vector2(1, -1)).normalized);
        }
        return(new Vector2(0, 0));
    }
Exemplo n.º 5
0
            internal List <Tuple <String, String> > GetAttributes()
            {
                var res = new List <Tuple <String, String> >();

                res.Add(new Tuple <String, String>("pole", Pole == PoleType.Left ? "left" : "right"));
                res.Add(new Tuple <String, String>("direction_x", DirectionX.ToString(CultureInfo.InvariantCulture)));
                res.Add(new Tuple <String, String>("direction_y", DirectionY.ToString(CultureInfo.InvariantCulture)));
                res.Add(new Tuple <String, String>("direction_z", DirectionZ.ToString(CultureInfo.InvariantCulture)));
                res.Add(new Tuple <String, String>("length", Length.ToString(CultureInfo.InvariantCulture)));
                res.Add(new Tuple <String, String>("state", State == MTState.Polymerization
                                                            ? "polymerization"
                                                            : "depolymerization"));
                return(res);
            }
Exemplo n.º 6
0
 public void SetDirectionX()
 {
     if (incrementX > 0)
     {
         directionX = DirectionX.Right;
     }
     else if (incrementX < 0)
     {
         directionX = DirectionX.Left;
     }
     else
     {
         directionX = DirectionX.Neutral;
     }
 }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (directionY != DirectionY.none)
        {
            Vector3 target = transform.position;
            if (directionY == DirectionY.up)
            {
                target = new Vector3(transform.position.x, transform.position.y, startY + offsetY);
                if (Vector3.Distance(transform.position, target) < 0.1f)
                {
                    directionY = DirectionY.down;
                }
            }
            else
            if (directionY == DirectionY.down)
            {
                target = new Vector3(transform.position.x, transform.position.y, startY - offsetY);
                if (Vector3.Distance(transform.position, target) < 0.1f)
                {
                    directionY = DirectionY.up;
                }
            }
            transform.position = Vector3.MoveTowards(transform.position, target, Time.deltaTime * speed);
        }

        if (directionX != DirectionX.none)
        {
            Vector3 target = transform.position;
            if (directionX == DirectionX.left)
            {
                target = new Vector3(startX - offsetX, transform.position.y, transform.position.z);
                if (Vector3.Distance(transform.position, target) < 0.1f)
                {
                    directionX = DirectionX.right;
                }
            }
            else
            if (directionX == DirectionX.right)
            {
                target = new Vector3(startX + offsetX, transform.position.y, transform.position.z);
                if (Vector3.Distance(transform.position, target) < 0.1f)
                {
                    directionX = DirectionX.left;
                }
            }
            transform.position = Vector3.MoveTowards(transform.position, target, Time.deltaTime * speed);
        }
    }
Exemplo n.º 8
0
 internal void Read(EndianBinaryReader reader)
 {
     EyeX.Read(reader);
     EyeY.Read(reader);
     EyeZ.Read(reader);
     PositionX.Read(reader);
     PositionY.Read(reader);
     PositionZ.Read(reader);
     DirectionX.Read(reader);
     DirectionY.Read(reader);
     DirectionZ.Read(reader);
     RotationX.Read(reader);
     RotationY.Read(reader);
     RotationZ.Read(reader);
     Zoom.Read(reader);
 }
Exemplo n.º 9
0
 internal void Write(EndianBinaryWriter writer)
 {
     EyeX.Write(writer);
     EyeY.Write(writer);
     EyeZ.Write(writer);
     PositionX.Write(writer);
     PositionY.Write(writer);
     PositionZ.Write(writer);
     DirectionX.Write(writer);
     DirectionY.Write(writer);
     DirectionZ.Write(writer);
     RotationX.Write(writer);
     RotationY.Write(writer);
     RotationZ.Write(writer);
     Zoom.Write(writer);
 }
        /// <summary>
        /// Gets the smallest correction required to resolve collisions along the X axis.
        /// </summary>
        /// <param name="directionX">The direction along the X axis to resolve.</param>
        /// <param name="correctionVectors">A list of CollisionVector2's detailing the resolutions required for all collisions that are occurring.</param>
        /// <returns>A CorrectionVector2 containing the smallest correction required.</returns>
        private CorrectionVector2 GetSmallestCorrectionX(DirectionX directionX, List <CorrectionVector2> correctionVectors)
        {
            CorrectionVector2 smallest = new CorrectionVector2();
            int i;

            smallest.X = int.MaxValue;

            for (i = 0; i < correctionVectors.Count; i++)
            {
                if (correctionVectors[i].DirectionX == directionX && correctionVectors[i].X != 0f && correctionVectors[i].X < smallest.X)
                {
                    smallest = correctionVectors[i];
                }
            }

            return(smallest);
        }
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                ComponentWithDirectionLogic comp = Owner as ComponentWithDirectionLogic;

                if (DirectionX.Contains(e.CanvasLocation))
                {
                    if (comp.Direction == FaceDirection.X)
                    {
                        return(GH_ObjectResponse.Handled);
                    }
                    comp.RecordUndoEvent("Direction X");
                    comp.Direction = FaceDirection.X;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }

                if (DirectionY.Contains(e.CanvasLocation))
                {
                    if (comp.Direction == FaceDirection.Y)
                    {
                        return(GH_ObjectResponse.Handled);
                    }
                    comp.RecordUndoEvent("Direction Y");
                    comp.Direction = FaceDirection.Y;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }

                if (DirectionZ.Contains(e.CanvasLocation))
                {
                    if (comp.Direction == FaceDirection.Z)
                    {
                        return(GH_ObjectResponse.Handled);
                    }
                    comp.RecordUndoEvent("Direction Z");
                    comp.Direction = FaceDirection.Z;
                    comp.ExpireSolution(true);
                    return(GH_ObjectResponse.Handled);
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemplo n.º 12
0
        private static void getDirAngles(double latDiff, double lonDiff, out DirectionX dirTravelX, out DirectionY dirTravelY)
        {
            // ---- Y direction of travel ----
            if (latDiff >= 0)
            {
                dirTravelY = DirectionY.North;
            }
            else
            {
                dirTravelY = DirectionY.South;
            }

            // ---- X direction of travel ----
            if (lonDiff >= 0)
            {
                dirTravelX = DirectionX.West;
            }
            else
            {
                dirTravelX = DirectionX.East;
            }
            // Might need a turn?? not sure?
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the smallest correction required to resolve collisions along the X axis.
        /// </summary>
        /// <param name="directionX">The direction along the X axis to resolve.</param>
        /// <param name="correctionVectors">A list of CollisionVector2's detailing the resolutions required for all collisions that are occurring.</param>
        /// <returns>A CorrectionVector2 containing the smallest correction required.</returns>
        private CorrectionVector2 GetSmallestCorrectionX(DirectionX directionX, List<CorrectionVector2> correctionVectors)
        {
            CorrectionVector2 smallest = new CorrectionVector2();
            int i;
            
            smallest.X = int.MaxValue;

            for (i = 0; i < correctionVectors.Count; i++)
            {
                if (correctionVectors[i].DirectionX == directionX && correctionVectors[i].X != 0f && correctionVectors[i].X < smallest.X)
                    smallest = correctionVectors[i];
            }

            return smallest;
        }
Exemplo n.º 14
0
        internal GeoCoordinate getGPSforTest(GeoCoordinate old, int forward, DirectionY dirY, int side, DirectionX dirX)
        {
            double lat = old.Latitude;
            double lon = old.Longitude;

            if (dirY == DirectionY.North)
            {
                lat += ((double)forward / (100000.0));
                if (dirX == DirectionX.West)
                {
                    lon = lon - ((double)side / (100000.0));
                }
                else
                {
                    lon = lon + ((double)side / (100000.0));
                }
            }
            else  //South
            {
                lat = lat - ((double)forward / (100000.0));

                if (dirX == DirectionX.West)
                {
                    lon = lon + ((double)side / (100000.0));
                }
                else
                {
                    lon = lon - ((double)side / (100000.0));
                }
            }

            return(new GeoCoordinate(lat, lon));  // Return new location
        }
Exemplo n.º 15
0
 public override string ToString()
 {
     return("PlaneSurface: " + "loc: " + Location.ToString() + "dirx: " + DirectionX.ToString() + "diry: " + DirectionY.ToString());
 }
        /// <summary>
        /// Returns a CorrectionVector2 containing the directions on the X and Y axis that the collision response is to be resolved.
        /// </summary>
        /// <param name="correctionVectors">A list of CorrectionVector2's, one for each of the collisions that need to be resolved.</param>
        /// <returns>A CorrectionVector2 with the DirectionX and DirectionY components set in the direction to perform the resolution.</returns>
        private CorrectionVector2 GetDirections(List <CorrectionVector2> correctionVectors)
        {
            CorrectionVector2 directions = new CorrectionVector2();
            int horizontalSum            = SumHorizontal(correctionVectors);
            int verticalSum = SumVertical(correctionVectors);

            DirectionX dirX = DirectionX.None;
            DirectionY dirY = DirectionY.None;

            if (horizontalSum <= (int)DirectionX.Left)
            {
                dirX = DirectionX.Left;
            }
            else if (horizontalSum >= (int)DirectionX.Right)
            {
                dirX = DirectionX.Right;
            }
            else
            {
                dirX = DirectionX.None; //If they cancel each other out, i.e 2 Left and 2 Right
            }
            if (verticalSum <= (int)DirectionY.Up)
            {
                dirY = DirectionY.Up;
            }
            else if (verticalSum >= (int)DirectionY.Down)
            {
                dirY = DirectionY.Down;
            }
            else
            {
                dirY = DirectionY.None; //If they cancel each other out, i.e 1 Up and 1 Down
            }
            directions.DirectionX = dirX;
            directions.DirectionY = dirY;

            //If both directions are None, then push out along the smallest for each
            if (directions.DirectionX == DirectionX.None && directions.DirectionY == DirectionY.None)
            {
                float smallestX = float.MaxValue;
                float smallestY = float.MaxValue;

                //Find the smallest X-axis and Y-axis correction...
                for (int i = 0; i < correctionVectors.Count; i++)
                {
                    if (correctionVectors[i].X < smallestX)
                    {
                        smallestX             = correctionVectors[i].X;
                        directions.DirectionX = correctionVectors[i].DirectionX;
                    }

                    if (correctionVectors[i].Y < smallestY)
                    {
                        smallestY             = correctionVectors[i].Y;
                        directions.DirectionY = correctionVectors[i].DirectionY;
                    }
                }
            }

            return(directions);
        }
Exemplo n.º 17
0
 internal double calc360Angle(DirectionX xDir, DirectionY yDir, double theta)
 {
     double angle;
     if (xDir == DirectionX.East)
     {
         angle = 90 - theta;   // North or south since eastSouth = neg Tan theta
         if (angle < 0)
             angle += 360;
     }
     else
     {
         if (yDir == DirectionY.North)
             angle = 270 + theta;
         else
             angle = 270 - theta;    // South
     }
     return angle;
 }
Exemplo n.º 18
0
        internal GeoCoordinate getGPSforTest(GeoCoordinate old, int forward, DirectionY dirY, int side, DirectionX dirX)
        {
            double lat = old.Latitude;
            double lon = old.Longitude;

            if (dirY == DirectionY.North)
            {
                lat += ((double)forward / (100000.0 ));
                if (dirX == DirectionX.West)
                    lon = lon - ((double)side / (100000.0 ));
                else
                    lon = lon + ((double)side / (100000.0 ));
            }
            else  //South
            {
                lat = lat - ((double)forward / (100000.0 ));

                if (dirX == DirectionX.West)
                    lon = lon + ((double)side / (100000.0));
                else
                    lon = lon - ((double)side / (100000.0 ));
            }

            return new GeoCoordinate(lat, lon);  // Return new location
        }
Exemplo n.º 19
0
        private static void getDirAngles(double latDiff, double lonDiff, out DirectionX dirTravelX, out DirectionY dirTravelY)
        {
            // ---- Y direction of travel ----
            if (latDiff >= 0)
                dirTravelY = DirectionY.North;
            else
                dirTravelY = DirectionY.South;

            // ---- X direction of travel ----
            if (lonDiff >= 0)
                dirTravelX = DirectionX.West;
            else
                dirTravelX = DirectionX.East;
                // Might need a turn?? not sure?
        }