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


C# MyVector.Clone方法代码示例

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


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

示例1: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            MyVector v1 = new MyVector(3, 4, 5);

            v1.Add(1, 2, 3);

            v1.BecomeUnitVector();

            MyVector v2 = v1.Clone();

            v2.Multiply(3);

            v1.Divide(3);
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:14,代码来源:VectorTester.cs

示例2: GetPositionViewToWorld

        /// <summary>
        /// If the user clicks on a picture box, you need to run those coords through this function to figure out where they
        /// clicked in world coords
        /// </summary>
        /// <param name="position">A point in PictureBox coords</param>
        /// <returns>The point in World Coords</returns>
        public MyVector GetPositionViewToWorld(MyVector position)
        {
            MyVector retVal = position.Clone();

            // Figure out the world coords that the top left of the picturebox represents
            double picLeft = _centerPoint.X - ((this.Width / 2d) / _zoom);
            double picTop = _centerPoint.Y - ((this.Height / 2d) / _zoom);

            // The point passed in is a distance from the top left of the picture box to where they clicked.  Turn this view
            // coords into world coords
            retVal.Divide(_zoom);

            // Add these world coords to the top left of the picture box
            retVal.X += picLeft;
            retVal.Y += picTop;

            // It's now what it needs to be
            return retVal;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:25,代码来源:LargeMapViewer2D.cs

示例3: StaticPoint

 /// <summary>
 /// This function tells me to look at the point passed in, but keep looking at where it is now, not actively track it.
 /// I will store the clone of it, so you don't have to make a clone before you pass me the pointer to a position
 /// </summary>
 public void StaticPoint(MyVector point)
 {
     _centerPoint = point.Clone();
 }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:8,代码来源:LargeMapViewer2D.cs

示例4: GetArbitraryOrhonganal

        /// <summary>
        /// This function will pick an arbitrary orthogonal to the vector passed in.  This will only be usefull if you are going
        /// to rotate 180
        /// </summary>
        public static MyVector GetArbitraryOrhonganal(MyVector vector)
        {
            // Clone the vector passed in
            MyVector retVal = vector.Clone();

            // Make sure that none of the values are equal to zero.
            if (retVal.X == 0) retVal.X = 0.000000001d;
            if (retVal.Y == 0) retVal.Y = 0.000000001d;
            if (retVal.Z == 0) retVal.Z = 0.000000001d;

            // Figure out the orthogonal X and Y slopes
            double orthM = (retVal.X * -1) / retVal.Y;
            double orthN = (retVal.Y * -1) / retVal.Z;

            // When calculating the new coords, I will default Y to 1, and find an X and Z that satisfy that.  I will go ahead and reuse the retVal
            retVal.Y = 1;
            retVal.X = 1 / orthM;
            retVal.Z = orthN;

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

示例5: BecomeUnitVector

        /// <summary>
        /// This creates a new vector that is the vector with a length of one
        /// </summary>
        public static MyVector BecomeUnitVector(MyVector vector)
        {
            MyVector retVal = vector.Clone();
            retVal.BecomeUnitVector();

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

示例6: 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

示例7: GetRotatedVector

        /// <summary>
        /// This function creates a vector that is the vector passed in rotated by my definition
        /// </summary>
        /// <param name="vector">The vector to rotate (I don't touch this vector, I create a new one that is rotated)</param>
        /// <param name="isQuatNormalized">Whether this class is already normalized or not (if you don't know, pass false)</param>
        public MyVector GetRotatedVector(MyVector vector, bool isQuatNormalized)
        {
            if (!isQuatNormalized)
            {
                // I'm not normalized, clone myself and normalize it
                MyQuaternion myUnitClone = new MyQuaternion(this.X, this.Y, this.Z, this.W);
                myUnitClone.BecomeUnitQuaternion();

                return myUnitClone.GetRotatedVector(vector, true);
            }

            MyVector qvec = new MyVector(this.X, this.Y, this.Z);

            //Vector uv = qvec.Cross(vector);
            MyVector uv = MyVector.Cross(qvec, vector);

            //Vector uuv = qvec.Cross(uv);
            MyVector uuv = MyVector.Cross(qvec, uv);

            //uv *= (2.0f * quat.w);
            uv.Multiply(this.W * 2d);

            //uuv *= 2.0f;
            uuv.Multiply(2d);

            //return vector + uv + uuv;
            MyVector retVal = vector.Clone();
            retVal.Add(uv);
            retVal.Add(uuv);
            return retVal;
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:36,代码来源:MyQuaternion.cs

示例8: picturebox_MouseDown

        void picturebox_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_active)
            {
                return;
            }

            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                _mouseDownPoint = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));
                _curMousePoint = _mouseDownPoint.Clone();
                _prevMousePositions.Clear();
                _tempStationaryObjects.Clear();		// this should be cleared by now anyway
            }

            if (e.Button == MouseButtons.Left)
            {
                #region Left

                _isMouseDown = MouseButtonDown.Left;

                // Get all the blips
                List<RadarBlip> remainingBlips = new List<RadarBlip>(_map.GetAllBlips());

                bool selectedPrevious = false;
                #region See if they selected one of the previously selected objects

                foreach (long token in _selectedObjects)
                {
                    RadarBlip blip = FindAndRemove(token, remainingBlips);

                    if (blip == null)
                    {
                        continue;
                    }

                    if (selectedPrevious)
                    {
                        // I just wanted to remove this blip from the total list
                        continue;
                    }

                    if (SelectionTest(blip, _curMousePoint))
                    {
                        selectedPrevious = true;
                    }
                }

                #endregion

                // Check for ctrl or shift key being pressed (if they are, don't clear the previous)
                if (!selectedPrevious && !(_isShiftPressed || _isCtrlPressed))
                {
                    _selectedObjects.Clear();
                }

                bool selectedNew = false;
                #region See if they clicked on any other objects

                foreach (RadarBlip blip in remainingBlips)
                {
                    if (SelectionTest(blip, _curMousePoint))
                    {
                        _selectedObjects.Add(blip.Token);
                        selectedNew = true;
                    }
                }

                #endregion

                // Set my mode
                if (selectedPrevious || selectedNew)
                {
                    _mode = SelectionMode.Selected;

                    #region Rebuild the offsets list (and temp stationary)

                    _draggingPositionOffsets.Clear();
                    foreach (RadarBlip blip in _map.GetAllBlips())
                    {
                        if (_selectedObjects.Contains(blip.Token))
                        {
                            _draggingPositionOffsets.Add(blip.Token, blip.Sphere.Position - _curMousePoint);

                            if (blip.CollisionStyle == CollisionStyle.Standard)
                            {
                                _tempStationaryObjects.Add(blip.Token);
                                blip.CollisionStyle = CollisionStyle.Stationary;
                            }
                        }
                    }

                    #endregion
                }
                else
                {
                    _mode = SelectionMode.Rectangle;
                }

                #endregion
//.........这里部分代码省略.........
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:101,代码来源:Selector.cs

示例9: 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

示例10: IsIntersecting_LinePlane

        /// <summary>
        /// If intersecting, this will return the point of intersection.  Otherwise null
        /// </summary>
        /// <param name="lineStartPoint">Starting point of the line</param>
        /// <param name="lineDirection">direction and length of the line</param>
        /// <param name="triangle">This represents the plane (3 arbitrary points on the plane)</param>
        /// <param name="limitToLineSegment">If false, the line passed in is thought of as infinitely long</param>
        /// <returns>point of intersection or null</returns>
        public static MyVector IsIntersecting_LinePlane(MyVector lineStartPoint, MyVector lineDirection, Triangle triangle, bool limitToLineSegment)
        {
            MyVector normal = triangle.Normal;

            double denominator = MyVector.Dot(normal, lineDirection);
            if (Utility3D.IsNearZero(denominator))		// parallel to the triangle's plane
            {
                return null;
            }

            double percentAlongLine = (triangle.DistanceFromOriginAlongNormal - MyVector.Dot(normal, lineStartPoint)) / denominator;

            if (limitToLineSegment && (percentAlongLine < 0d || percentAlongLine > 1d))
            {
                // The ray is intersecting, but they want the line segment only
                return null;
            }

            // Calculate the point along the line
            MyVector retVal = lineDirection.Clone();
            double length = retVal.GetMagnitude();
            retVal.Divide(length);
            retVal.Multiply(percentAlongLine * length);
            retVal.Add(lineStartPoint);

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

示例11: GetCollisionNormalAndPointsOfContact_SphereSphere

        protected void GetCollisionNormalAndPointsOfContact_SphereSphere(out MyVector normal, out double normalMagnitude, out MyVector pointOfContact1, out MyVector pointOfContact2, BallBlip ball1, BallBlip ball2)
        {
            // Vector that is perpendicular to the tangent of the collision, and it points in the direction of object 1.  Real
            // easy when dealing with spheres     :)
            normal = ball2.Ball.Position - ball1.Ball.Position;

            // Remember this length
            normalMagnitude = normal.GetMagnitude();

            // This needs to be returned as a unit vector
            normal.Divide(normalMagnitude);

            // Start them off as unit vectors
            pointOfContact1 = normal.Clone();
            pointOfContact2 = normal.Clone();

            // Finish (use the ratio of their radii)
            pointOfContact1.Multiply((ball1.Ball.Radius / (ball1.Ball.Radius + ball2.Ball.Radius)) * normalMagnitude);
            pointOfContact2.Multiply((ball2.Ball.Radius / (ball1.Ball.Radius + ball2.Ball.Radius)) * normalMagnitude * -1);		// I want this one pointing the other direction

            // Now that I have the points of contact relative to the centers of position, I need to make them
            // relative to the centers of mass
            if (ball1.TorqueBall != null)
            {
                pointOfContact1.Subtract(ball1.TorqueBall.CenterOfMass);
            }

            if (ball2.TorqueBall != null)
            {
                pointOfContact2.Subtract(ball2.TorqueBall.CenterOfMass);
            }
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:32,代码来源:CollisionHandler.cs

示例12: SplitForceIntoTranslationAndTorque

        private static void SplitForceIntoTranslationAndTorque(out MyVector translationForce, out MyVector torque, MyVector centerOfMass, MyVector offset, MyVector force)
        {
            // The offset passed in is relative to position.  I need it to be relative to the center of mass
            MyVector trueOffset = offset - centerOfMass;

            // Torque is how much of the force is applied perpendicular to the radius
            torque = MyVector.Cross(trueOffset, force);

            // I'm still not convinced this is totally right, but none of the articles I've read seem to do anything
            // different
            translationForce = force.Clone();
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:12,代码来源:TorqueBall.cs

示例13: picturebox_MouseDown

        void picturebox_MouseDown(object sender, MouseEventArgs e)
        {
            if (_mode == AddingMode.Inactive)
            {
                return;
            }

            if (e.Button == MouseButtons.Left)
            {
                _isMouseDown = true;
                _mouseDownPoint = _picturebox.GetPositionViewToWorld(new MyVector(e.X, e.Y, 0));
                _curMousePoint = _mouseDownPoint.Clone();
                _lastCreateTime = Environment.TickCount;
                _createdBallDuringMouseDrag = false;
                //_diminishPercent = 1d;

                if (_newBallProps.SizeMode == BallProps.SizeModes.Draw)
                {
                    // I need to create an object now (but don't commit it to the map), so that the user can see
                    // it while they drag the size
                    _drawingBall = BuildObject();
                }
            }
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:24,代码来源:BallAdder.cs

示例14: 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

示例15: GetSpinVelocityAtPoint

        private MyVector GetSpinVelocityAtPoint(ref AngularVelocityInfo angularInfo, out MyVector dirToCenterLine, MyVector dirFacingWorld, MyVector lineBetween, MyVector blipPosition)
        {
            // Get a line that's orthogonal to lineBetween, and always points toward the dirFacingWorld vector
            dirToCenterLine = MyVector.Cross(MyVector.Cross(lineBetween, dirFacingWorld), lineBetween);
            dirToCenterLine.BecomeUnitVector();

            if (angularInfo == null)
            {
                #region Cache Angular Velocity

                angularInfo = new AngularVelocityInfo();

                if (_ship.TorqueBall != null)
                {
                    angularInfo.AngularVelocity = _ship.TorqueBall.AngularVelocity.GetMagnitude();

                    angularInfo.SpinDirection = MyVector.Cross(_ship.TorqueBall.AngularVelocity, _ship.TorqueBall.DirectionFacing.Standard);
                    angularInfo.SpinDirection.BecomeUnitVector();

                    angularInfo.CenterMass = _ship.TorqueBall.Rotation.GetRotatedVector(_ship.TorqueBall.CenterOfMass, true);
                    angularInfo.CenterMass.Add(_ship.TorqueBall.Position);
                }
                else
                {
                    angularInfo.SpinDirection = dirToCenterLine.Clone();
                    angularInfo.AngularVelocity = 0d;
                    angularInfo.CenterMass = _ship.Ball.Position.Clone();
                }

                #endregion
            }

            // Get the line between the blip and the center of mass
            MyVector lineBetweenCM = blipPosition - angularInfo.CenterMass;

            // Figure out my velocity of spin where the blip is
            return angularInfo.SpinDirection * (angularInfo.AngularVelocity * lineBetweenCM.GetMagnitude());
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:38,代码来源:TractorBeamCone.cs


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