当前位置: 首页>>代码示例>>C#>>正文


C# Vector2.Angle方法代码示例

本文整理汇总了C#中System.Vector2.Angle方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Angle方法的具体用法?C# Vector2.Angle怎么用?C# Vector2.Angle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Vector2的用法示例。


在下文中一共展示了Vector2.Angle方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: isFirable

 public bool isFirable(Vector2 RightStick)
 {
     if(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Rad2Deg(RightStick.Angle(directionVector))<10 && Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Rad2Deg(RightStick.Angle(directionVector))>-10)
         return true;
     else
         return false;
 }
开发者ID:cytricks,项目名称:PSMSS,代码行数:7,代码来源:PlayerClass.cs

示例2: SimpleEnemy

        public SimpleEnemy(Vector2 bond)
        {
            //rand;

            position = new Vector2(rand.Next(0,960),rand.Next(0,544));

            direction = new Vector2( rand.Next(-101,101)/100,rand.Next(-101,101)/100);

            bounds = new Vector2(bond.X,bond.Y);

            if(texture==null)
                texture = new Texture2D("/Application/textures/tri.png", false);

            CompareVector = new Vector2(0,-1);
            rotationAngle = CompareVector.Angle(direction);
        }
开发者ID:cytricks,项目名称:PSMSS,代码行数:16,代码来源:SimpleEnemy.cs

示例3: CalculateNextGasAmount

        public void CalculateNextGasAmount()
        {
            if (blocking)
                return;
            double DAmount;
            double Flow = 0;
            

            GasCell neighbor;
            Random rand = new Random();
            for (int i = -1; i <= 1; i++)
                for (int j = -1; j <= 1; j++)
                {
                    if (i == 0 && j == 0) // If we're on this cell
                        continue;
                    if (arrX + i < 0 || arrX + i > 38 || arrY + j < 0 || arrY + j > 38) // If out of bounds
                        continue;

                    neighbor = cellArray[arrX+i,arrY+j];
                    if (neighbor.calculated || neighbor.blocking) // TODO work out rebound
                        continue;

                    DAmount = gasAmount - neighbor.gasAmount;
                    if (DAmount == 0 || Math.Abs(DAmount) < 0.1)
                    {
                        return;
                    }

                    ///Calculate initial flow
                    Flow = FlowConstant * DAmount;
                    Flow = Clamp(Flow, gasAmount / 8, neighbor.gasAmount / 8);

                    //Velocity application code
                    Vector2 Dir = new Vector2(i, j);
                    double proportion = 0;
                    double componentangle;
                    //Process velocity flow to neighbor
                    if (GasVel.Magnitude > 0.01) //If the gas velocity vector is within 45 degrees of the direction of the neighbor
                    {
                        componentangle = Dir.Angle(GasVel);
                        if (Math.Abs(componentangle) < quarterpi)
                        {
                            proportion = Math.Abs((1 / quarterpi) * (quarterpi - componentangle)); // Get the proper proportion of the vel vector
                            double velflow = proportion * GasVel.Magnitude; // Calculate flow due to gas velocity
                            if (velflow > gasAmount / 2.5)
                                velflow = gasAmount / 2.5;
                            Flow += velflow;
                        }
                    }
                    //Process velocity flow from neighbor
                    Dir = -1 * Dir; // Reverse Dir and apply same process to neighbor
                    if (neighbor.GasVel.Magnitude > 0.01) //If the gas velocity vector is within 45 degrees of the direction of the neighbor
                    {
                        componentangle = Dir.Angle(neighbor.GasVel);
                        if (Math.Abs(componentangle) < quarterpi)
                        {
                            proportion = Math.Abs((1 / quarterpi) * (quarterpi - componentangle)); // Get the proper proportion of the vel vector
                            double velflow = proportion * neighbor.GasVel.Magnitude; // Calculate flow due to gas velocity
                            if (velflow > neighbor.gasAmount / 2.5)
                                velflow = neighbor.gasAmount / 2.5;
                            Flow -= velflow;
                        }
                    }

                    nextGasAmount -= Flow;
                    neighbor.nextGasAmount += Flow;

                    double chaos = (double)rand.Next(70000, 100000)/100000; // Get a random number between .7 and 1 with 4 sig figs

                    //Process next velocities
                    if (Flow > 0) //Flow is to neighbor
                    {
                        Vector2 addvel = new Vector2(i, j);
                        addvel.Magnitude = Math.Abs(Flow); // Damping coefficient of .5
                        neighbor.NextGasVel = neighbor.NextGasVel + addvel * chaos * RecieverDamping;
                        NextGasVel = NextGasVel + addvel * chaos * SourceDamping;
                    }
                    if (Flow < 0) // Flow is from neighbor
                    {
                        Vector2 addvel = new Vector2(-1 * i, -1 * j);
                        addvel.Magnitude = Math.Abs(Flow);
                        neighbor.NextGasVel = neighbor.NextGasVel + addvel * chaos * SourceDamping;
                        NextGasVel = NextGasVel + addvel * chaos * RecieverDamping;

                    }



                    // Rescue clause. If this is needed to avoid crashes, something is wrong
                    /*if(nextGasAmount < 0)
                        nextGasAmount = 0;
                    if (neighbor.nextGasAmount < 0)
                        neighbor.nextGasAmount = 0;
                      */
                    calculated = true;
                }
        }
开发者ID:RedSkotina,项目名称:ss13remake,代码行数:97,代码来源:GasCell.cs

示例4: SearchIntermediate

        /// <summary>
        /// Searches intermediate significant points, judged from the angle
        /// of their vector to the general direction of the stroke
        /// </summary>
        private void SearchIntermediate()
        {
            Vector2 vStrokeDirection = new Vector2(BeginPoint, EndPoint);
            //if angle between points is really different,
            //create a new intermediate point.

            IntermediatePoints = new List<Point>();
            IntermediatePoints.Add(BeginPoint);

            if (AllPoints.Count > 5)
            {
                for (int i = 5; i < AllPoints.Count; i++)
                {
                    Vector2 v = new Vector2(AllPoints[i - 5], AllPoints[i]);
                    if (v.Angle(vStrokeDirection) > Math.PI / 4)
                    {
                        IntermediatePoints.Add(AllPoints[i]);
                    }
                }
            }
            IntermediatePoints.Add(EndPoint);
            //the code above does this now
            //var result =
            //    from point in allpoints
            //    where point.positionvector().angle(vstrokedirection) > math.pi / 4
            //    select point;

            //intermediatepoints = new list<point>(result);
        }
开发者ID:sbpnlp,项目名称:kanjiteacher,代码行数:33,代码来源:Stroke.cs

示例5: CalculateNextGasAmount

        public void CalculateNextGasAmount(IMapManager m)
        {
            if (calculated)
                return;

            if (!attachedTile.GasPermeable)
                return;

            float DAmount;

            GasCell neighbor;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if (i == 0 && j == 0) // If we're on this cell
                        continue;

                    Tile t = neighbours[i + 1, j + 1];
                    if (t == null || t.gasCell == null)
                        continue;

                    neighbor = t.gasCell;

                    if (Math.Abs(i) + Math.Abs(j) == 2) //If its a corner
                    {
                        if (!neighbours[i + 1, 1].GasPermeable && !neighbours[1, j + 1].GasPermeable)
                        {
                            // And it is a corner separated from us by 2 blocking walls
                            continue; //Don't process it. These cells are not connected.
                        }
                    }

                    if (neighbor.Calculated) // if neighbor's already been calculated, skip it
                        continue;

                    if (neighbor.attachedTile.GasPermeable)
                    {
                        if (gasMixture.Burning || neighbor.gasMixture.Burning)
                        {
                            neighbor.gasMixture.Expose();
                            gasMixture.Expose();
                        }
                        DAmount = GasMixture.Pressure - neighbor.GasMixture.Pressure;
                        if (Math.Abs(DAmount) < 50.0f)
                        {
                            GasMixture.Diffuse(neighbor.GasMixture);
                        }
                        else
                        {

                            var neighDir = new Vector2(i, j);
                            float angle = 0.0f;
                            float pAmount = 0.0f;
                            float proportion = 0.075f;

                            if (gasVel.Magnitude > 0.0f)
                            {
                                angle = (float)Math.Abs(neighDir.Angle(gasVel));
                                if (Math.Abs(angle) < quarterpi)
                                {
                                    pAmount += VelClamp((float)gasVel.Magnitude);//Clamp(GasMixture.Pressure / neighbor.GasMixture.Pressure);
                                    proportion += Math.Abs(((1f / quarterpi) * (quarterpi - angle)) * pAmount);// (float)GasVel.Magnitude / 100f);
                                }
                            }

                            if (neighbor.gasVel.Magnitude > 0.0f)
                            {
                                var Dir = neighDir * -1;
                                angle = (float)Math.Abs(Dir.Angle(neighbor.gasVel));
                                if (angle < quarterpi)
                                {
                                    pAmount += VelClamp((float)neighbor.gasVel.Magnitude); //Clamp(neighbor.GasMixture.Pressure / GasMixture.Pressure);
                                    proportion += Math.Abs(((1f / quarterpi) * (quarterpi - angle)) * pAmount);//(float)neighbor.GasVel.Magnitude / 1000f));
                                }
                            }
                            if (proportion > 0.3f)
                                proportion = 0.3f;

                            if (proportion > 0.0f)
                            {
                                GasMixture.Diffuse(neighbor.GasMixture, 1f / proportion);
                                neighbor.NextGasVel += new Vector2(DAmount * proportion * i, DAmount * proportion * j) * RecieverDamping;
                                NextGasVel += new Vector2(DAmount * proportion * i, DAmount * proportion * j) * SourceDamping;
                            }
                        }
                    }

                    #region old gas code

                    /*
                    if (DAmount == 0 || Math.Abs(DAmount) < 10)
                    {
                        gasMixture.Diffuse(neighbor.gasMixture);
                        return;
                    }

                    Log.LogManager.Log("High pressure difference");
                    ///Calculate initial flow
                    Flow = FlowConstant * DAmount;
//.........这里部分代码省略.........
开发者ID:Gartley,项目名称:ss13remake,代码行数:101,代码来源:GasCell.cs

示例6: LerpUnitVectors

 /// <summary>Lerp 2 (assumed) unit vectors (shortest path).</summary>
 public static Vector2 LerpUnitVectors( Vector2 va, Vector2 vb, float x )
 {
     return va.Rotate( va.Angle( vb ) * x );
 }
开发者ID:artron33,项目名称:PsmFramework,代码行数:5,代码来源:Math.cs

示例7: Move

        public void Move( float X, float Y ,Vector2 RightStick)
        {
            position.Y-=Y*ySpeed;
            position.X+=X*xSpeed;

            if(position.Y < 0)
                position.Y=0;

            if(position.X < 0)
                position.X=0;

            if(position.Y > bounds.Y)
                position.Y=bounds.Y;

            if(position.X > bounds.X)
                position.X=bounds.X;

            temp = new Vector2(RightStick.X, RightStick.Y);

            Vector2 CompareVector = new Vector2(0,-1);

            if(!directionVector.IsUnit(1)){
                directionVector = directionVector.Divide(directionVector.Length());
            }

            if(!RightStick.IsUnit(1)){
                RightStick = RightStick.Divide(RightStick.Length());
            }

            directionVector = directionVector.Add(RightStick);
            directionVector = directionVector.Divide(2);

            //			if(RightStick.X < .1 && RightStick.X > -.1)
            //				RightStick.X = 0;
            //
            //			if(RightStick.Y < .1 && RightStick.Y > -.1)
            //				RightStick.Y = 0;

            if(RightStick.X != 0 || RightStick.Y != 0) {
                RotationAngle = CompareVector.Angle(directionVector);//CompareVector.Angle(RightStick);
            }
            else {
                //RotationAngle = 0;
            }

            //			if(RotationAngle < 0 && currentAngle-RotationAngle >0 )
            //				currentAngle -= .1f;
            //			else if(RotationAngle < 0)
            //				currentAngle += .1f;
            //
            //			if(RotationAngle > 0 && currentAngle-RotationAngle <0 )
            //				currentAngle += .1f;
            //			else if(RotationAngle > 0)
            //				currentAngle -= .1f;
        }
开发者ID:cytricks,项目名称:PSMSS,代码行数:55,代码来源:PlayerClass.cs


注:本文中的System.Vector2.Angle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。