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


C# Vector3.Dot方法代码示例

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


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

示例1: Quaternion

        /// <summary>
        /// Initializes a new instance of the <see cref="Quaternion"/> class.
        /// </summary>
        /// <param name="sourcePosition">The source position.</param>
        /// <param name="destinationPosition">The destination position.</param>
        public Quaternion(Vector3 sourcePosition, Vector3 destinationPosition)
        {
            var r = sourcePosition.Cross(destinationPosition);
            var s = Functions.Sqrt(2 * (1 + sourcePosition.Dot(destinationPosition)));

            mValues = new Vector4(r / s, s / 2);
        }
开发者ID:Christof,项目名称:afterglow,代码行数:12,代码来源:Quaternion.cs

示例2: DistanceXZ

 /// 2点間の距離を返す(XとZのみ)
 public static float DistanceXZ( Vector3 pos1, Vector3 pos2 )
 {
     calPos = pos1 - pos2;
     calPos.Y = 0;
     float dis = FMath.Sqrt( calPos.Dot(calPos) );
     return dis;
 }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:8,代码来源:VectorUtil.cs

示例3: MeshTriangle

        public MeshTriangle(byte id, Vector3 p0, Vector3 p1, Vector3 p2)
        {
            Id = id;
            P0 = p0;
            P1 = p1;
            P2 = p2;

            Points = new List<Vector3>{P0, P1, P2};
            U = P1 - P0;
            V = P2 - P0;
            Normal = U.Cross(V).NormalizeRet();

            Direction = CalculateDirection();
            UU = U.Dot(U);
            VV = V.Dot(V);
            UV = U.Dot(V);

            D = UV * UV - UU * VV;
        }
开发者ID:HaKDMoDz,项目名称:Psy,代码行数:19,代码来源:MeshTriangle.cs

示例4: AngleBetweenVectors

        static double AngleBetweenVectors(Vector3 Vector1, Vector3 Vector2)
        {
            float dotProduct = Vector1.Dot(Vector2);
            float vectorsMagnitude = Vector1.Length * Vector2.Length;
            double angle = Math.Acos(dotProduct / vectorsMagnitude);

            if (double.IsNaN(angle))
                return 0;
            return (angle);
        }
开发者ID:Cram974,项目名称:noobzone,代码行数:10,代码来源:Collision.cs

示例5: VecToRad

        /// <summary>
        /// 2つのベクトルがなす角をかえす
        /// </summary>
        /// <param name="vecA"></param>
        /// <param name="vecB"></param>
        /// <returns></returns>
        public static double VecToRad( Vector3 vecA, Vector3 vecB )
        {
            vecA.Normalize();
            vecB.Normalize();

            double dir = (double)(Axiom.Math.Utility.ASin(vecA.Dot(vecB)) - Axiom.Math.Utility.HALF_PI);
            Vector3 resVec = vecA.Cross(vecB);
            if (resVec.z < 0) dir = -dir;

            return dir;
        }
开发者ID:terakenxx,项目名称:TukubaChallenge,代码行数:17,代码来源:Rooting.cs

示例6: GetAngleBetweenVectors

        public double GetAngleBetweenVectors(Vector3 a, Vector3 b)
        {
            var cosAlpha = a.Dot(b) / (a.Magnitude * b.Magnitude);

            if (1 - Math.Abs(cosAlpha) < Consts.DoubleEqualityThreshold)
            {
                return cosAlpha < 0 ? Math.PI : 0;
            }

            return Math.Acos(cosAlpha);
        }
开发者ID:jbarson,项目名称:KineticsTool,代码行数:11,代码来源:VectorLibrary.cs

示例7: CurveFrame

        /// <summary>
        /// Sets up the frame
        /// </summary>
        /// <param name="position"> Frame origin </param>
        /// <param name="velocity"> Velocity. Becomes frame tangent (normalised by constructor) </param>
        /// <param name="acceleration"> Acceleration. Used to calculate frame normal and binormal </param>
        public CurveFrame( Point3 position, Vector3 velocity, Vector3 acceleration )
        {
            float	sqrSpeed	= velocity.SqrLength;
            float	dotVA		= velocity.Dot( acceleration );

            Translation	= position;
            XAxis		= velocity.MakeNormal( );
            YAxis		= ( acceleration * sqrSpeed ) - ( velocity * dotVA );
            ZAxis		= Vector3.Cross( XAxis, YAxis );
            m_Speed		= Functions.Sqrt( sqrSpeed );

            //	NOTE: It's quite easy to calculate curvature here (because we've got first and second derivatives, and the square of speed, ready at hand).
            //	I've removed the calculation because it does involve a length and a cross-product, which is a bit much if the caller isn't interested in the
            //	curvature value (as is likely). Call Curve.EvaluateCurvature() instead.
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:21,代码来源:CurveFrame.cs

示例8: Integrate

 public void Integrate(float duration)
 {
     if (!IsAwake) return;
     LastFrameAcceleration = Acceleration;
     LastFrameAcceleration += (ForceAccumulation * InverseMass);
     Vector3 angularAcceleration = InverseInertiaTensorWorld.Transform(TorqueAccumulation);
     Velocity += (LastFrameAcceleration * duration);
     Rotation += (angularAcceleration * duration);
     Velocity *= MathHelper.Pow(LinearDrag, duration);
     Rotation *= MathHelper.Pow(AngularDrag, duration);
     Position += (Velocity * duration);
     Orientation.AddScaledVector(Rotation, duration);
     CalculateDerivedData();
     ClearAccumulation();
     if (CanSleep)
     {
         float currentMotion = Velocity.Dot(Velocity) + Rotation.Dot(Rotation);
         float bias = MathHelper.Pow(0.5f, duration);
         Motion = bias * Motion + (1.0f - bias) * currentMotion;
         if (Motion < MathHelper.SleepEpilson) IsAwake = (false);
         else if (Motion > 10 * MathHelper.SleepEpilson) Motion = 10.0f * MathHelper.SleepEpilson;
     }
 }
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:23,代码来源:RigidBody.cs

示例9: Plane

 /// <summary>
 ///		Construct a plane from 3 coplanar points.
 /// </summary>
 /// <param name="point0">First point.</param>
 /// <param name="point1">Second point.</param>
 /// <param name="point2">Third point.</param>
 public Plane(Vector3 point0, Vector3 point1, Vector3 point2)
 {
     Vector3 edge1 = point1 - point0;
     Vector3 edge2 = point2 - point0;
     Normal = edge1.Cross(edge2);
     Normal.Normalize();
     D = -Normal.Dot(point0);
 }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:14,代码来源:Plane.cs

示例10: GetAutoSplatSampleNormalized

        public float[] GetAutoSplatSampleNormalized( long heightMM, Vector3 normal )
        {
            AutoSplatHeightAngleRange lowerRange = null;
            AutoSplatHeightAngleRange higherRange = null;

            // We assume the ranges are sorted in increasing order by height
            foreach( AutoSplatHeightAngleRange range in m_RangeList )
            {
                if( range.HeightMM == heightMM )
                {
                    lowerRange = range;
                    higherRange = range;
                    break;
                }

                if( range.HeightMM < heightMM )
                {
                    lowerRange = range;
                    continue;
                }

                if( range.HeightMM > heightMM )
                {
                    higherRange = range;
                    // We should have both the lower & upper bounds now, so break;
                    break;
                }
            }

            if( lowerRange == null )
            {
                lowerRange = m_RangeList[ 0 ]; // allows us to continue
            }
            if( higherRange == null )
            {
                higherRange = m_RangeList[ m_RangeList.Count - 1 ]; // allows us to continue
            }

            // We want the angle of the normal relative to the XZ plane, so
            // we first use the dot product to get the angle to the Y-axis
            // which is perpendicular to the XZ plane, convert it to degress,
            // and then subtract it from 90.
            float angleRadians = normal.Dot( Vector3.UnitY );
            float angleDegrees = Convert.ToSingle( 90 - RadiansToDegrees( angleRadians ) );

            if( lowerRange == higherRange )
            {
                // No need to do any weighting since we at the exact height
                return lowerRange.GetAutoSplatSampleNormalized( angleDegrees );
            }

            // Compute the gradiant weighting for the lower & higher angled textures
            float lowerWeight;
            float higherWeight;

            long heightDiff = higherRange.HeightMM - lowerRange.HeightMM;

            if( heightDiff == 0 )
            {
                // Give equal weighting to both samples.
                // This covers the case when we have two ranges at the
                // same height....this really shouldn't happen due to the
                // way we choose the lower/higher ranges.
                lowerWeight = 0.5f;
                higherWeight = 0.5f;
            }
            else
            {
                // How close is the angle to the higher/lower angle?  Normalize
                // that distance from 0..1 and use that as the gradient weights
                higherWeight = ((float) (heightMM - lowerRange.HeightMM)) / heightDiff;
                lowerWeight = 1f - higherWeight;
            }

            float[] lowerNormalizedSample = lowerRange.GetAutoSplatSampleNormalized( angleDegrees );
            float[] higherNormalizedSample = higherRange.GetAutoSplatSampleNormalized( angleDegrees );

            float[] normalizedSample = new float[ AlphaSplatTerrainConfig.MAX_LAYER_TEXTURES ];
            for( int i = 0; i < AlphaSplatTerrainConfig.MAX_LAYER_TEXTURES; i++ )
            {
                normalizedSample[ i ] = lowerNormalizedSample[ i ] * lowerWeight +
                                      higherNormalizedSample[ i ] * higherWeight;
            }
            return normalizedSample;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:85,代码来源:AutoSplatRules.cs

示例11: TransformPlane

		internal void TransformPlane( float[] norm, ref float dist )
		{
			TransformVector( norm, true );
			dist *= this.options.scale;
			var normal = new Vector3( norm[ 0 ], norm[ 1 ], norm[ 2 ] );
			Vector3 point = normal*dist;
			point += this.options.move;
			dist = normal.Dot( point );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:9,代码来源:Quake3Level.cs

示例12: Vector3

        /// <summary>
        /// Concatenates two quaternions. The right argument is applied first.
        /// </summary>
        /// <param name="left">The left operand which is applied after the right one.</param>
        /// <param name="right">The right operand which is applied first.</param>
        /// <returns>A quaternion containing the rotations of both given quaternions.</returns>
        public static Quaternion operator *(Quaternion left, Quaternion right)
        {
            var v1 = new Vector3(right.X, right.Y, right.Z);
            var v2 = new Vector3(left.X, left.Y, left.Z);

            var w = left.W * right.W - v1.Dot(v2);
            var v = right.W * v2 + left.W * v1 + v2.Cross(v1);

            return new Quaternion(v, w);
        }
开发者ID:Christof,项目名称:afterglow,代码行数:16,代码来源:Quaternion.cs

示例13: Reflect

 public static void Reflect(ref Vector3 vector, ref Vector3 planeNormal, out Vector3 result)
 {
     result = vector - (planeNormal * vector.Dot(planeNormal) * 2);
 }
开发者ID:reignstudios,项目名称:ReignSDK,代码行数:4,代码来源:Vector3.cs

示例14: InersectNormal

 public static void InersectNormal(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
 {
     result = (normal * vector.Dot(normal));
 }
开发者ID:reignstudios,项目名称:ReignSDK,代码行数:4,代码来源:Vector3.cs

示例15: half_diff_coords_to_std_coords

        public static void half_diff_coords_to_std_coords( double _ThetaHalf, double _PhiHalf, double _ThetaDiff, double _PhiDiff,
													ref Vector3 _In, ref Vector3 _Out )
        {
            double	SinTheta_half = Math.Sin( _ThetaHalf );
            Half.Set( Math.Cos( _PhiHalf ) * SinTheta_half, Math.Sin( _PhiHalf ) * SinTheta_half, Math.Cos( _ThetaHalf ) );

            // Build the 2 vectors representing the frame in which we can use the diff angles
            Vector3	OrthoX;
            Half.Cross( ref Normal, out OrthoX );
            if ( OrthoX.LengthSq() < 1e-6 )
                OrthoX.Set( 1, 0, 0 );
            else
                OrthoX.Normalize();

            Vector3	OrthoY;
            Half.Cross( ref OrthoX, out OrthoY );

            // Rotate using diff angles to retrieve incoming direction
            Half.Rotate( ref OrthoX, -_ThetaDiff, out Temp );
            Temp.Rotate( ref Half, _PhiDiff, out _In );

            // ...or by mirroring in "Half tangent space"
            double	MirrorX = -_In.Dot( ref OrthoX );
            double	MirrorY = -_In.Dot( ref OrthoY );
            double	z = _In.Dot( ref Half );
            _Out.Set(
                MirrorX*OrthoX.x + MirrorY*OrthoY.x + z*Half.x,
                MirrorX*OrthoX.y + MirrorY*OrthoY.y + z*Half.y,
                MirrorX*OrthoX.z + MirrorY*OrthoY.z + z*Half.z
            );

            // 			if ( _In.z < -0.5 || _Out.z < -0.5 )
            // 				throw new Exception( "RHA MAIS MERDE!" );
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:34,代码来源:DisplayForm.cs


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