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


C# Vector类代码示例

本文整理汇总了C#中Vector的典型用法代码示例。如果您正苦于以下问题:C# Vector类的具体用法?C# Vector怎么用?C# Vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AddForce

 public void AddForce(Vector worldForce, Vector worldOffset)
 {
     //add linar force
     m_forces += worldForce;
     //and it's associated torque
     m_torque += worldOffset % worldForce;
 }
开发者ID:zenmumbler,项目名称:GranZero,代码行数:7,代码来源:RigidBody.cs

示例2: Zoom

        private static double Zoom(CompiledFunc func, Vector x, Vector dir, double aLow, double aHigh, double fZero, double diffZero)
        {
            var normDir = dir.Normalize();
            double aMid = 0;
            double fValue = 0;
            double diff = 0;

            while (Math.Abs(aLow - aHigh) > EPS)
            {
                aMid = aLow + (aHigh - aLow)/2;
                fValue = func.Eval(x + aMid*dir);

                if (fValue > fZero + C1*aMid*diffZero || fValue >= func.Eval(x + aLow*dir))
                    aHigh = aMid;
                else
                {
                    diff = (func.Differentiate(x + aMid*dir)*normDir).Sum();

                    if (Math.Abs(diff) <= -C2*diffZero)
                        return aMid;

                    if (diff*(aHigh - aLow) >= 0)
                        aHigh = aLow;

                    aLow = aMid;
                }
            }

            return aMid;
        }
开发者ID:renehernandez,项目名称:SharpOptimization,代码行数:30,代码来源:LinearSearch.cs

示例3: LinearSolve

 /// <summary>
 /// Solves a linear system through inversing a matrix
 /// </summary>
 /// <param name="paramM"></param>
 /// <param name="yV"></param>
 /// <returns></returns>
 public Vector LinearSolve(Matrix paramM, Vector yV)
 {
     if (!paramM.IsSquare() || paramM.Height != yV.Dim)
         throw new Exception("Dim Error");
     Vector xV = paramM.Inverse() * yV;
     return xV;
 }
开发者ID:numcat,项目名称:Machine-Learning-Collection,代码行数:13,代码来源:Solver.cs

示例4: Write

 public static void Write(this BinaryWriter writer, Vector vector)
 {
     writer.Write(vector.X);
     writer.Write(vector.Y);
     writer.Write(vector.Z);
     writer.Write(vector.W);
 }
开发者ID:klosejiang,项目名称:Magic-Hands,代码行数:7,代码来源:Tools.cs

示例5: Move

 public void Move(Vector offset)
 {
     foreach(Node node in Nodes) {
         node.X += offset.X;
         node.Y += offset.Y;
     }
 }
开发者ID:BackupTheBerlios,项目名称:supertux-svn,代码行数:7,代码来源:Path.cs

示例6: D

 public override float D(ref Vector wh)
 {
     float costhetah = Math.Abs(BrdfBase.CosTheta(ref wh));
     return (exponent + 2f) *
            MathLab.INVTWOPI *
            (float)Math.Pow(Math.Max(0f, costhetah), exponent);
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:BlinnDistribution.cs

示例7: GaussianQuadrature

      public GaussianQuadrature(int n, GaussianOrthogonalPolynomial orthPoly)
      {
         x_ = new Vector(n);
         w_ = new Vector(n);

        // set-up matrix to compute the roots and the weights
        Vector e = new Vector(n-1);

        int i;
        for (i=1; i < n; ++i) 
        {
            x_[i] = orthPoly.alpha(i);
            e[i-1] = Math.Sqrt(orthPoly.beta(i));
        }
        x_[0] = orthPoly.alpha(0);

        TqrEigenDecomposition tqr = new TqrEigenDecomposition( x_, e,
                               TqrEigenDecomposition.EigenVectorCalculation.OnlyFirstRowEigenVector,
                               TqrEigenDecomposition.ShiftStrategy.Overrelaxation);

        x_ = tqr.eigenvalues();
        Matrix ev = tqr.eigenvectors();

        double mu_0 = orthPoly.mu_0();
        for (i=0; i<n; ++i) {
            w_[i] = mu_0*ev[0,i]*ev[0,i] / orthPoly.w(x_[i]);
        }
      }
开发者ID:akasolace,项目名称:qlnet,代码行数:28,代码来源:GaussianQuadratures.cs

示例8: PinholeCamera

 public PinholeCamera(Point eye, Point lat, Vector up, float fov)
 {
     this.eye = eye;
     this.lat = lat;
     this.up = up;
     this.fov = fov;
 }
开发者ID:dknutsen,项目名称:dokray,代码行数:7,代码来源:Camera.cs

示例9: DisturbVector

 public override void DisturbVector(Vector<double> vecToBeDisturbed)
 {
     double[] samples = new double[vecToBeDisturbed.Count];
     _gauss.Samples(samples);
     for(int i = 0; i < vecToBeDisturbed.Count; ++i)
         vecToBeDisturbed.At(i, vecToBeDisturbed.At(i) + (double)samples[i]);
 }
开发者ID:KFlaga,项目名称:Cam3D,代码行数:7,代码来源:NoiseGenerators.cs

示例10: Slide

	private Notes _notes; // usermodel needs to Set this

	/**
	 * Constructs a Slide from the Slide record, and the SlideAtomsSet
	 *  Containing the text.
	 * Initialises TextRuns, to provide easier access to the text
	 *
	 * @param slide the Slide record we're based on
	 * @param notes the Notes sheet attached to us
	 * @param atomSet the SlideAtomsSet to Get the text from
	 */
	public Slide(NPOI.HSLF.record.Slide slide, Notes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
        base(slide, slideIdentifier);

		_notes = notes;
		_atomSet = atomSet;
		_slideNo = slideNumber;

 		// Grab the TextRuns from the PPDrawing
		TextRun[] _otherRuns = FindTextRuns(getPPDrawing());

		// For the text coming in from the SlideAtomsSet:
		// Build up TextRuns from pairs of TextHeaderAtom and
		//  one of TextBytesAtom or TextCharsAtom
		Vector textRuns = new Vector();
		if(_atomSet != null) {
			FindTextRuns(_atomSet.GetSlideRecords(),textRuns);
		} else {
			// No text on the slide, must just be pictures
		}

		// Build an array, more useful than a vector
		_Runs = new TextRun[textRuns.Count+_otherRuns.Length];
		// Grab text from SlideListWithTexts entries
		int i=0;
		for(i=0; i<textRuns.Count; i++) {
			_Runs[i] = (TextRun)textRuns.Get(i);
            _Runs[i].SetSheet(this);
		}
		// Grab text from slide's PPDrawing
		for(int k=0; k<_otherRuns.Length; i++, k++) {
			_Runs[i] = _otherRuns[k];
            _Runs[i].SetSheet(this);
		}
	}
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:45,代码来源:Slide.cs

示例11: Write

 public static void Write(this BinaryWriter bw, Vector vector)
 {
     bw.Write(vector.X);
     bw.Write(vector.Y);
     bw.Write(vector.Z);
     bw.Write(vector.W);
 }
开发者ID:philipdaubmeier,项目名称:BodyOrientation,代码行数:7,代码来源:KinectRawFeatureSet.cs

示例12: AAverageLogarithm

 /// <summary>
 /// VMP message to 'A'.
 /// </summary>
 /// <param name="X">Incoming message from 'X'. Must be a proper distribution.  If any element is uniform, the result will be uniform.</param>
 /// <param name="A">Incoming message from 'A'.</param>
 /// <param name="result">Modified to contain the outgoing message.</param>
 /// <returns><paramref name="result"/></returns>
 /// <remarks><para>
 /// The outgoing message is the exponential of the integral of the log-factor times incoming messages, over all arguments except 'A'.
 /// The formula is <c>int log(f(A,x)) q(x) dx</c> where <c>x = (X,B)</c>.
 /// </para></remarks>
 /// <exception cref="ImproperMessageException"><paramref name="X"/> is not a proper distribution</exception>
 /// <exception cref="ImproperMessageException"><paramref name="B"/> is not a proper distribution</exception>
 public static VectorGaussianArray AAverageLogarithm([SkipIfAllUniform] GaussianArray2D X, [SkipIfAllUniform] VectorGaussianArray B, [SkipIfAllUniform] VectorGaussianArray result)
 {
     int I = X.GetLength(0), J = X.GetLength(1), K = B[0].Dimension;
     var Ebbp = new PositiveDefiniteMatrix[J];
     var mb = new Vector[J];
     for (int j = 0; j < J; j++)
     {
         Ebbp[j] = new PositiveDefiniteMatrix(K, K);
         mb[j] = Vector.Zero(K);
         B[j].GetMeanAndVariance(mb[j], Ebbp[j]);
         Ebbp[j].SetToSumWithOuter(Ebbp[j], 1, mb[j], mb[j]);
     }
     for (int i = 0; i < I; i++)
     {
         result[i].Precision.SetAllElementsTo(0);
         result[i].MeanTimesPrecision.SetAllElementsTo(0);
         for (int j = 0; j < J; j++)
         {
             // nb: would be more memory efficient to have a SetToAPlusCB routine
             result[i].Precision.SetToSum(result[i].Precision, Ebbp[j] * X[i, j].Precision);
             result[i].MeanTimesPrecision.SetToSum(result[i].MeanTimesPrecision, mb[j] * X[i, j].MeanTimesPrecision);
         }
     }
     return result;
 }
开发者ID:dtrckd,项目名称:Mixed-Membership-Stochastic-Blockmodel,代码行数:38,代码来源:VectorMatrixMultiplyOp.cs

示例13: UserCmd

 public UserCmd()
 {
     ViewAngles = new Vector();
     HeadAngles = new Vector();
     HeadOffset = new Vector();
     CrosshairTrace = new Vector();
 }
开发者ID:vhsoaresr,项目名称:Dota2,代码行数:7,代码来源:UserCmd.cs

示例14: dfx

        // f' by x  (df[i] by dx[j])
        //пользователь вводит производную каждой функции фи по каждому х
        public double dfx(Vector xt, double t, ref Vector z, int i, int j)
        {
            double[] ut = new double[dimU];
            Program.control(t, ref z, ref ut);

            return evaluate(ref xdtdx[i, j], ref xt, ut[0], 0, t);
        }
开发者ID:RCnowak,项目名称:diploma,代码行数:9,代码来源:Task.cs

示例15: CalculateForce

    public Vector CalculateForce(Vector relativeGroundSpeed, float timeStep)
    {
        //calculate speed of tire patch at ground
        Vector patchSpeed = -m_forwardAxis * m_wheelSpeed * m_wheelRadius;

        //get velocity difference between ground and patch
        Vector velDifference = relativeGroundSpeed + patchSpeed;

        //project ground speed onto side axis
        float forwardMag = 0;
        Vector sideVel = velDifference.Project(m_sideAxis);
        Vector forwardVel = velDifference.Project(m_forwardAxis, out forwardMag);

        //calculate super fake friction forces
        //calculate response force
        Vector responseForce = -sideVel * 2.0f;
        responseForce -= forwardVel;

        //calculate torque on wheel
        m_wheelTorque += forwardMag * m_wheelRadius;

        //integrate total torque into wheel
        m_wheelSpeed += m_wheelTorque / m_wheelInertia * timeStep;

        //clear our transmission torque accumulator
        m_wheelTorque = 0;

        //return force acting on body
        return responseForce;
    }
开发者ID:zenmumbler,项目名称:GranZero,代码行数:30,代码来源:Wheel.cs


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