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


C# Vector3.LengthSquared方法代码示例

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


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

示例1: SetForce

        public void SetForce(Vector3 force)
        {
            if (force.LengthSquared() > 1.0f)
                force.Normalize();

            mController.Force = GameOptions.MovementForce * force;
        }
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:7,代码来源:FlyerControllerComponent.cs

示例2: LocalGetSupportingVertexWithoutMargin

		// optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp
		//public class Hull m_optionalHull;

		public override Vector3 LocalGetSupportingVertexWithoutMargin(Vector3 vec)
		{
			Vector3 supVec = new Vector3();

			float maxDot = -1e30f;

			float lenSqr = vec.LengthSquared();
			if (lenSqr < 0.0001f)
			{
				vec = new Vector3(1, 0, 0);
			}
			else
			{
				float rlen = 1f / (float)Math.Sqrt(lenSqr);
				vec *= rlen;
			}

			Vector3 vtx;
			float newDot;

			for (int i = 0; i < VertexCount; i++)
			{
				GetVertex(i, out vtx);
				newDot = Vector3.Dot(vec, vtx);
				if (newDot > maxDot)
				{
					maxDot = newDot;
					supVec = vtx;
				}
			}
			return supVec;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:35,代码来源:PolyhedralConvexShape.cs

示例3: Extend

        public static Vector3 Extend(Vector3 value, float min)
        {
            float minSquared = min*min;
            float vectorSquared = value.LengthSquared();

            if (vectorSquared >= minSquared || vectorSquared == 0)
                return value;
            else
                return value*(min/(float) Math.Sqrt(vectorSquared));
        }
开发者ID:rc183,项目名称:igf,代码行数:10,代码来源:Vector3Extensions.cs

示例4: Truncate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="max"></param>
        public static Vector3 Truncate(Vector3 value, float max)
        {
            float maxSquared = max * max;
            float vectorSquared = value.LengthSquared();

            if (vectorSquared <= maxSquared)
                return value;
            else
                return value * (max / (float)Math.Sqrt(vectorSquared));
        }
开发者ID:rc183,项目名称:igf,代码行数:15,代码来源:Vector3Extensions.cs

示例5: ProjectVector3D

 public static void ProjectVector3D(ref Vector3 vec, ref Vector3 projectOn, out Vector3 result)
 {
     float dp;
     Vector3.Dot(ref vec, ref projectOn, out dp);
     float oneOnLenSqr = 1.0f / projectOn.LengthSquared();
     result = new Vector3(
                 dp * oneOnLenSqr * projectOn.X,
                 dp * oneOnLenSqr * projectOn.Y,
                 dp * oneOnLenSqr * projectOn.Y);
 }
开发者ID:gnomicstudios,项目名称:GGJ13,代码行数:10,代码来源:VectorUtils.cs

示例6: update

			public void update()
			{
				velocity += _acceleration;
				position += velocity;
				_acceleration = Vector3.Zero;
				if( velocity.LengthSquared() < 0.001f * 0.001f )
					velocity = Vector3.Zero;

				velocity *= _damping;
				_damping = 0.98f;
			}
开发者ID:prime31,项目名称:Nez,代码行数:11,代码来源:SpringGrid.cs

示例7: GetExtremePoint

        ///<summary>
        /// Gets the extreme point of the shape in world space in a given direction with margin expansion.
        ///</summary>
        ///<param name="direction">Direction to find the extreme point in.</param>
        /// <param name="shapeTransform">Transform to use for the shape.</param>
        ///<param name="extremePoint">Extreme point on the shape.</param>
        public void GetExtremePoint(Vector3 direction, ref RigidTransform shapeTransform, out Vector3 extremePoint)
        {
            GetExtremePointWithoutMargin(direction, ref shapeTransform, out extremePoint);

            float directionLength = direction.LengthSquared();
            if (directionLength > Toolbox.Epsilon)
            {
                Vector3.Multiply(ref direction, collisionMargin / (float)Math.Sqrt(directionLength), out direction);
                Vector3.Add(ref extremePoint, ref direction, out extremePoint);
            }

        }
开发者ID:Indiefreaks,项目名称:igf,代码行数:18,代码来源:ConvexShape.cs

示例8: MovingLevelPiece

 public MovingLevelPiece(Game game, GameplayScreen host, String assetName, Vector3 pMovement, float pMoveSpeed)
     : base(game, host, assetName)
 {
     m_movement = pMovement;
     m_moveVelocity = m_movement;
     if (m_moveVelocity.LengthSquared() != 0)
     {
         m_moveVelocity.Normalize();
     }
     //50 is a good number, fyi
     m_moveVelocity *= pMoveSpeed;
     m_currentMovement = Vector3.Zero;
 }
开发者ID:vu159951,项目名称:xnasuperdragonball,代码行数:13,代码来源:MovingLevelPiece.cs

示例9: NormalizeSafe

 /// <summary>
 /// 正規化された Vector3 を取得します。
 /// もしも Vector3 がゼロ ベクトルである場合にはゼロ ベクトルを返します。
 /// </summary>
 /// <param name="vector">Vector3。</param>
 /// <param name="result">正規化された Vector3。</param>
 public static void NormalizeSafe(ref Vector3 vector, out Vector3 result)
 {
     var lengthSquared = vector.LengthSquared();
     if (lengthSquared != 0.0f)
     {
         var coeff = 1.0f / (float) Math.Sqrt(lengthSquared);
         result.X = vector.X * coeff;
         result.Y = vector.Y * coeff;
         result.Z = vector.Z * coeff;
     }
     else
     {
         result = vector;
     }
 }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:21,代码来源:Vector3Extension.cs

示例10: contains

        public override bool contains(Vector3 point)
        {
            Vector3 _p = new Vector3(point.X - Position.X, point.Y - Position.Y, point.Z - Position.Z);
            //Vector3 _p2 = Vector3.Transform(_p, Matrix.CreateFromQuaternion(Orientation));

            if (_p.Y >= 0 && _p.Y <= m_height)
            {
                if (_p.LengthSquared() < (m_radius * m_radius))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:DelBero,项目名称:XnaScrap,代码行数:15,代码来源:CylinderCollider.cs

示例11: InertialMoveBehavior

        public InertialMoveBehavior(Vector3 v, float a, float mv)
            : base()
        {
            MaxSpeed = mv;
            Accel = a;

            if (v.LengthSquared() == 0)
            {
                Speed = 0;
                Direction = new Vector3();
            }
            else
            {
                Speed = v.Length();
                v.Normalize();
                Direction = v;
            }
        }
开发者ID:bigbadrat,项目名称:XnaGame,代码行数:18,代码来源:SimpleMovementBehaviors.cs

示例12: GetLocalExtremePointWithoutMargin

        ///<summary>
        /// Gets the extreme point of the shape in local space in a given direction.
        ///</summary>
        ///<param name="direction">Direction to find the extreme point in.</param>
        ///<param name="extremePoint">Extreme point on the shape.</param>
        public override void GetLocalExtremePointWithoutMargin(ref Vector3 direction, out Vector3 extremePoint)
        {
            //Is it the tip of the cone?
            float sinThetaSquared = radius * radius / (radius * radius + height * height);
            //If d.Y * d.Y / d.LengthSquared >= sinthetaSquared
            if (direction.Y > 0 && direction.Y * direction.Y >= direction.LengthSquared() * sinThetaSquared)
            {
                extremePoint = new Vector3(0, .75f * height, 0);
                return;
            }
            //Is it a bottom edge of the cone?
            float horizontalLengthSquared = direction.X * direction.X + direction.Z * direction.Z;
            if (horizontalLengthSquared > Toolbox.Epsilon)
            {
                var radOverSigma = radius / Math.Sqrt(horizontalLengthSquared);
                extremePoint = new Vector3((float)(radOverSigma * direction.X), -.25f * height, (float)(radOverSigma * direction.Z));
            }
            else // It's pointing almost straight down...
                extremePoint = new Vector3(0, -.25f * height, 0);


        }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:27,代码来源:ConeShape.cs

示例13: VectorsDirectionEqual

 public static bool VectorsDirectionEqual(Vector3 vec1, Vector3 vec2, float allowedError)
 {
     float len1 = vec1.LengthSquared();
     float len2 = vec2.LengthSquared();
     float dot = Vector3.Dot(vec1, vec2);
     if(!(dot<0.0f))
         dot *= dot / (len1 * len2);
     return dot < 0.0f ? false : 1.0f - dot < allowedError;
 }
开发者ID:lancelot2112,项目名称:XerUtilities,代码行数:9,代码来源:MathLib.cs

示例14: Update

            public void Update()
            {
                Velocity += acceleration;
                Position += Velocity;
                acceleration = Vector3.Zero;
                if (Velocity.LengthSquared() < 0.001f * 0.001f)
                    Velocity = Vector3.Zero;

                Velocity *= damping;
                damping = 0.98f;
            }
开发者ID:hvp,项目名称:Squareosity,代码行数:11,代码来源:Grid.cs

示例15: Project

 public static Vector3 Project(this Vector3 v, Vector3 on)
 {
     return v.Dot(on) / on.LengthSquared() * on;
 }
开发者ID:ZetaTwo,项目名称:Project-Easter-Egg,代码行数:4,代码来源:PointAndVectorExtensions.cs


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