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


C# MyVector.RotateAroundAxis方法代码示例

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


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

示例1: chkIncludeShip_CheckedChanged

        private void chkIncludeShip_CheckedChanged(object sender, EventArgs e)
        {
            const double THRUSTERANGLE = 75;

            if (chkIncludeShip.Checked)
            {
                if (_ship == null)
                {
                    #region Create Ship

                    // Set up the ship
                    double radius = MINRADIUSMASS + (_rand.NextDouble() * (MAXRADIUSMASS - MINRADIUSMASS));
                    SolidBall ship = new SolidBall(Utility3D.GetRandomVector(_boundryLower, _boundryUpper), new DoubleVector(0, 1, 0, 1, 0, 0), radius, GetMass(radius), GetElasticity(), 1, 1, _boundryLower, _boundryUpper);

                    // Set up the thrusters
                    MyVector thrusterSeed = new MyVector(0, ship.Radius, 0);
                    MyVector zAxis = new MyVector(0, 0, 1);

                    // Bottom Thrusters
                    _shipThrusterOffset_BottomRight = thrusterSeed.Clone();
                    _shipThrusterOffset_BottomRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(THRUSTERANGLE * -1));

                    _shipThrusterOffset_BottomLeft = thrusterSeed.Clone();
                    _shipThrusterOffset_BottomLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(THRUSTERANGLE));

                    // Top Thrusters
                    thrusterSeed = new MyVector(0, ship.Radius * -1, 0);
                    _shipThrusterOffset_TopRight = thrusterSeed.Clone();
                    _shipThrusterOffset_TopRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(THRUSTERANGLE));

                    _shipThrusterOffset_TopLeft = thrusterSeed.Clone();
                    _shipThrusterOffset_TopLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(THRUSTERANGLE * -1));

                    // Add to the map
                    _ship = new BallBlip(ship, CollisionStyle.Standard, RadarBlipQual.BallUserDefined03, TokenGenerator.NextToken());
                    _map.Add(_ship);

                    #endregion
                }
            }
            else
            {
                if (_ship != null)
                {
                    _map.Remove(_ship.Token);
                    _ship = null;
                }
            }
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:49,代码来源:MapTester1.cs

示例2: GetRandomVectorSpherical2D

        public static MyVector GetRandomVectorSpherical2D(double maxRadius)
        {
            MyVector retVal = new MyVector(GetNearZeroValue(maxRadius), 0, 0);

            MyVector rotateAxis = new MyVector(0, 0, 1);
            double radians = GetNearZeroValue(2d * Math.PI);

            retVal.RotateAroundAxis(rotateAxis, radians);

            return retVal;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:11,代码来源:Utility3D.cs

示例3: trackBar_Scroll

        private void trackBar_Scroll(object sender, EventArgs e)
        {
            // Figure out the vector to rotate around
            MyVector rotateAround = new MyVector(trkXAxis.Value, trkYAxis.Value, trkZAxis.Value);

            if (rotateAround.X == 0 && rotateAround.Y == 0 && rotateAround.Z == 0)
            {
                pictureBox1.CreateGraphics().Clear(Color.Tomato);
                return;
            }

            // Rotate a vector
            MyVector rotatedVector = new MyVector(9, 0, 0);
            rotatedVector.RotateAroundAxis(rotateAround, Utility3D.GetDegreesToRadians(trackBar1.Value));

            // Draw it
            ClearPictureBox();
            DrawVector(rotateAround, Color.LightSteelBlue);
            DrawVector(rotatedVector, Color.GhostWhite);
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:20,代码来源:VectorTester.cs

示例4: DrawVelocity

        private Bitmap DrawVelocity()
        {
            const double MINLENGTHPERCENT = 0d;
            const double MAXLENGTHPERCENT = 1d;
            const double MINTARGET = 10d;
            const double MAXTARGET = 250d;

            #region Figure out the length

            // Figure out how long the real velocity will be
            double realVelocity = 0d;

            if (_exposedProps.RandomVelocity)
            {
                realVelocity = _exposedProps.MaxVelocity * .75d;
            }
            else
            {
                if (_exposedProps.Velocity != null && !_exposedProps.Velocity.IsZero)
                {
                    realVelocity = _exposedProps.Velocity.GetMagnitude();
                }
            }

            // Figure out the velocity to draw
            double velocityPercent = 0d;
            if (realVelocity >= MINLENGTHPERCENT)
            {
                velocityPercent = UtilityCore.GetScaledValue_Capped(MINLENGTHPERCENT, MAXLENGTHPERCENT, MINTARGET, MAXTARGET, realVelocity);
            }

            #endregion

            // Figure out the color
            Color velocityColor = GetGreenRedColor(MINTARGET, MAXTARGET, realVelocity, velocityPercent);

            float halfSize = _buttonSize * .5f;

            Bitmap retVal = new Bitmap(_buttonSize + 1, _buttonSize + 1);
            using (Graphics graphics = Graphics.FromImage(retVal))
            {
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                if (velocityPercent > 0d)
                {
                    double drawLength = (_buttonSize / 2d) * velocityPercent;

                    // Draw Vector
                    using (Pen vectorPen = new Pen(velocityColor, 2f))
                    {
                        vectorPen.StartCap = LineCap.Round;	// LineCap.RoundAnchor;
                        vectorPen.EndCap = LineCap.ArrowAnchor;

                        MyVector vectorLine;
                        if (_exposedProps.RandomVelocity)
                        {
                            // Draw a circle underneath
                            using (Pen circlePen = new Pen(SystemColors.ControlDark, 1f))
                            {
                                graphics.DrawEllipse(circlePen, Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(drawLength * 2d), Convert.ToSingle(drawLength * 2d));
                            }

                            vectorLine = new MyVector(drawLength, 0, 0);

                            vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-60d));
                            graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                            vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-85d));
                            graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                            vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-150d));
                            graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                        }
                        else
                        {
                            vectorLine = _exposedProps.Velocity.Clone();
                            vectorLine.BecomeUnitVector();
                            vectorLine.Multiply(drawLength);

                            graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));
                        }
                    }
                }
            }

            // Exit Function
            return retVal;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:89,代码来源:SolidBallPropsMenu.cs

示例5: DrawSize

        private Bitmap DrawSize()
        {
            const double MINRADIUSPERCENT = .15d;
            const double MAXRADIUSPERCENT = 1d;
            const double MINTARGET = 20d;
            const double MAXTARGET = 1000d;

            #region Figure out the radius

            // Figure out how big the real ball will be
            double ballRadius = 0;

            switch (_exposedProps.SizeMode)
            {
                case BallProps.SizeModes.Draw:
                    //TODO:  Use a different line color
                    ballRadius = UtilityCore.GetScaledValue(MINTARGET, MAXTARGET, 0d, 1d, .75d);
                    break;

                case BallProps.SizeModes.Fixed:
                    ballRadius = _exposedProps.SizeIfFixed;
                    break;

                case BallProps.SizeModes.Random:
                    ballRadius = (_exposedProps.MinRandSize + _exposedProps.MaxRandSize) / 2d;
                    break;

                default:
                    throw new ApplicationException("Unknown BallProps.SizeModes: " + _exposedProps.SizeMode.ToString());
            }

            // Figure out the radius to draw
            double radiusPercent = UtilityCore.GetScaledValue_Capped(MINRADIUSPERCENT, MAXRADIUSPERCENT, MINTARGET, MAXTARGET, ballRadius);

            #endregion

            // Figure out the color
            Color radiusColor = GetGreenRedColor(MINTARGET, MAXTARGET, ballRadius, radiusPercent);

            float drawWidth = Convert.ToSingle((_buttonSize - 2) * radiusPercent);
            float halfDrawWidth = drawWidth * .5f;
            float halfSize = (_buttonSize - 2) * .5f;

            Bitmap retVal = new Bitmap(_buttonSize, _buttonSize);
            using (Graphics graphics = Graphics.FromImage(retVal))
            {
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                // Draw Radius
                using (Pen radiusPen = new Pen(radiusColor, 2f))
                {
                    MyVector radiusLine = new MyVector(halfDrawWidth, 0, 0);
                    radiusLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-30d));

                    graphics.DrawLine(radiusPen, halfSize, halfSize, Convert.ToSingle(halfSize + radiusLine.X), Convert.ToSingle(halfSize + radiusLine.Y));
                }

                // Draw Circle
                Color circleColor = Color.Black;
                if (_exposedProps.SizeMode == BallProps.SizeModes.Draw)
                {
                    circleColor = SystemColors.ControlDark;
                }

                using (Pen circlePen = new Pen(circleColor, 2f))
                {
                    graphics.DrawEllipse(circlePen, halfSize - halfDrawWidth, halfSize - halfDrawWidth, drawWidth, drawWidth);
                }
            }

            // Exit Function
            return retVal;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:73,代码来源:SolidBallPropsMenu.cs

示例6: trackBar1_Scroll

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            MyVector thrusterSeed = new MyVector(0, _ship.Radius, 0);
            MyVector zAxis = new MyVector(0, 0, 1);
            double angle = trackBar1.Value;

            // Bottom Thrusters
            _shipThrusterOffset_BottomRight = thrusterSeed.Clone();
            _shipThrusterOffset_BottomRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(angle * -1));

            _shipThrusterOffset_BottomLeft = thrusterSeed.Clone();
            _shipThrusterOffset_BottomLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(angle));

            // Top Thrusters
            thrusterSeed = new MyVector(0, _ship.Radius * -1, 0);
            _shipThrusterOffset_TopRight = thrusterSeed.Clone();
            _shipThrusterOffset_TopRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(angle));

            _shipThrusterOffset_TopLeft = thrusterSeed.Clone();
            _shipThrusterOffset_TopLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(angle * -1));
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:21,代码来源:SolidBallTester.cs

示例7: PropsChangedSprtThrusters

        private void PropsChangedSprtThrusters()
        {
            if (_type != ShipTypeQual.SolidBall)
            {
                return;  // the ball just has the thruster in the center
            }

            MyVector thrusterSeed = new MyVector(0, _ship.Ball.Radius, 0);
            MyVector zAxis = new MyVector(0, 0, 1);

            // Bottom Thrusters
            _thrusterOffset_BottomRight = thrusterSeed.Clone();
            _thrusterOffset_BottomRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle * -1));

            _thrusterOffset_BottomLeft = thrusterSeed.Clone();
            _thrusterOffset_BottomLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle));

            // Top Thrusters
            thrusterSeed = new MyVector(0, _ship.Ball.Radius * -1, 0);
            _thrusterOffset_TopRight = thrusterSeed.Clone();
            _thrusterOffset_TopRight.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle));

            _thrusterOffset_TopLeft = thrusterSeed.Clone();
            _thrusterOffset_TopLeft.RotateAroundAxis(zAxis, Utility3D.GetDegreesToRadians(_thrusterAngle * -1));
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:25,代码来源:ShipController.cs

示例8: DrawVelocity

        private void DrawVelocity(PieMenuDrawButtonArgs e)
        {
            const double MINLENGTHPERCENT = 0d;
            const double MAXLENGTHPERCENT = 1d;
            const double MINTARGET = 10d;
            const double MAXTARGET = 250d;

            #region Figure out the length

            // Figure out how long the real velocity will be
            double realVelocity = 0d;

            if (this.ExposedProps.RandomVelocity)
            {
                realVelocity = this.ExposedProps.MaxVelocity * .75d;
            }
            else
            {
                if (this.ExposedProps.Velocity != null && !this.ExposedProps.Velocity.IsZero)
                {
                    realVelocity = this.ExposedProps.Velocity.GetMagnitude();
                }
            }

            // Figure out the velocity to draw
            double velocityPercent = 0d;
            if (realVelocity >= MINLENGTHPERCENT)
            {
                velocityPercent = UtilityCore.GetScaledValue_Capped(MINLENGTHPERCENT, MAXLENGTHPERCENT, MINTARGET, MAXTARGET, realVelocity);
            }

            #endregion

            // Figure out the color
            Color velocityColor = GetGreenRedColor(MINTARGET, MAXTARGET, realVelocity, velocityPercent);

            float halfSize = e.ButtonSize * .5f;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            if (velocityPercent > 0d)
            {
                #region Draw Vector

                double drawLength = (e.ButtonSize / 2d) * velocityPercent;

                // Draw Vector
                using (Pen vectorPen = new Pen(velocityColor, 2f))
                {
                    vectorPen.StartCap = LineCap.Round;	// LineCap.RoundAnchor;
                    vectorPen.EndCap = LineCap.ArrowAnchor;

                    MyVector vectorLine;
                    if (this.ExposedProps.RandomVelocity)
                    {
                        // Draw a circle underneath
                        using (Pen circlePen = new Pen(SystemColors.ControlDark, 1f))
                        {
                            e.Graphics.DrawEllipse(circlePen, Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(drawLength * 2d), Convert.ToSingle(drawLength * 2d));
                        }

                        vectorLine = new MyVector(drawLength, 0, 0);

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-60d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-85d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-150d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                    }
                    else
                    {
                        vectorLine = this.ExposedProps.Velocity.Clone();
                        vectorLine.BecomeUnitVector();
                        vectorLine.Multiply(drawLength);

                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));
                    }
                }

                #endregion
            }
            else
            {
                e.Graphics.DrawString("Velocity", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
            }

        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:91,代码来源:SolidBallProps.cs


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