示例#1
3
	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);
		}
	}
示例#2
0
            public override HashSet<Vector> Find(TerrainGrid terrain)
            {
                var interestPoints = new HashSet<Vector>();

                var blocking = new Grid<bool>(terrain.Size);
                foreach (var point in terrain.GetPoints())
                {
                    var terrainType = terrain[point];
                    blocking[point] = TerrainTypes.Blocking.Contains(terrainType);
                }

                blocking = _filters.Close(blocking);

                var areas = _areaFinder.Find(blocking).ToList();
                areas.RemoveAll((area) => area.Count <= 20);
                foreach (var area in areas)
                {
                    var areaList = area.ToList();
                    int xMean = (int)areaList.Average((p) => p.x);
                    int yMean = (int)areaList.Average((p) => p.y);
                    Vector centroid = new Vector(xMean, yMean);
                    interestPoints.Add(centroid);
                }

                return interestPoints;
            }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "ItemAutoSubscription" /> class.
 /// </summary>
 /// <param name = "item">
 ///   The subscribed item.
 /// </param>
 /// <param name = "itemPosition">
 ///   The item position.
 /// </param>
 /// <param name = "itemRegion">
 ///   The item Region.
 /// </param>
 /// <param name = "subscription">
 ///   The subscription.
 /// </param>
 public ItemAutoSubscription(Item item, Vector itemPosition, Region itemRegion, IDisposable subscription)
 {
     this.ItemPosition = itemPosition;
     this.item = item;
     this.subscription = subscription;
     this.WorldRegion = itemRegion;
 }
示例#4
0
        public void Test()
        {
            double k = 1.0;
            double theta = 0.02;
            double sigma = 0.08;
            double r0 = 0.01;
            Vector par = new Vector(3);
            par[0] = k;
            par[1] = theta;
            par[2] = sigma;

            double strike = 0.98;
            double noz = 100.0;

            double T = 1.0;
            double S = 2.0;

            double callFairmat = noz * CIRCap.BondCall(r0, 0.0, T, S, strike, par);
            double callBenchmark = 0.317304505282290;

            Console.WriteLine("CallFairmat   = " + callFairmat);
            Console.WriteLine("CallBenchmark = " + callBenchmark);

            double maxError = 1e-10;
            Assert.Less(Math.Abs(callFairmat - callBenchmark), maxError);
        }
示例#5
0
    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;
    }
示例#6
0
文件: Camera.cs 项目: dknutsen/dokray
 public PinholeCamera(Point eye, Point lat, Vector up, float fov)
 {
     this.eye = eye;
     this.lat = lat;
     this.up = up;
     this.fov = fov;
 }
示例#7
0
      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]);
        }
      }
示例#8
0
 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]);
 }
 /// <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;
 }
 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);
 }
示例#11
0
 public UserCmd()
 {
     ViewAngles = new Vector();
     HeadAngles = new Vector();
     HeadOffset = new Vector();
     CrosshairTrace = new Vector();
 }
示例#12
0
 public void AddForce(Vector worldForce, Vector worldOffset)
 {
     //add linar force
     m_forces += worldForce;
     //and it's associated torque
     m_torque += worldOffset % worldForce;
 }
示例#13
0
        private void EvalBrdf(ref Vector wo, ref Vector wi, ref Normal N, out RgbSpectrum fs)
        {
            float cosThetaO = Vector.AbsDot(ref N, ref wo);
            //AbsCosTheta(wo);
            float cosThetaI = Vector.AbsDot(ref N, ref wi);
            //AbsCosTheta(wi);
            if (Math.Abs(cosThetaI - 0f) < Epsilon || Math.Abs(cosThetaO - 0f) < Epsilon)
            {
                fs = new RgbSpectrum(0f, 0f, 0f);
                return;
                //return new RgbSpectrum(1f, 0f, 0f);
            }
            Vector wh = wi + wo;
            if (wh.IsZero())
            {
                fs = new RgbSpectrum(0f);
                return;
            }
            //return new RgbSpectrum(1f, 0f, 0f);
            wh = wh.Normalize();
            float cosThetaH = Vector.Dot(ref wi, ref wh);
            var F = fresnel.Evaluate(cosThetaH);

            fs = (R0 * distr.D(ref wh) * G(ref N, ref wo, ref wi, ref wh) * F / (4f * cosThetaI * cosThetaO));
        }
示例#14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EllipseGeometry"/> class.
        /// </summary>
        /// <param name="rect">The rectangle that the ellipse should fill.</param>
        public EllipseGeometry(Rect rect)
        {
            IPlatformRenderInterface factory = PerspexLocator.Current.GetService<IPlatformRenderInterface>();
            IStreamGeometryImpl impl = factory.CreateStreamGeometry();

            using (IStreamGeometryContextImpl ctx = impl.Open())
            {
                double controlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3;
                var center = rect.Center;
                var radius = new Vector(rect.Width / 2, rect.Height / 2);

                var x0 = center.X - radius.X;
                var x1 = center.X - (radius.X * controlPointRatio);
                var x2 = center.X;
                var x3 = center.X + (radius.X * controlPointRatio);
                var x4 = center.X + radius.X;

                var y0 = center.Y - radius.Y;
                var y1 = center.Y - (radius.Y * controlPointRatio);
                var y2 = center.Y;
                var y3 = center.Y + (radius.Y * controlPointRatio);
                var y4 = center.Y + radius.Y;

                ctx.BeginFigure(new Point(x2, y0), true);
                ctx.BezierTo(new Point(x3, y0), new Point(x4, y1), new Point(x4, y2));
                ctx.BezierTo(new Point(x4, y3), new Point(x3, y4), new Point(x2, y4));
                ctx.BezierTo(new Point(x1, y4), new Point(x0, y3), new Point(x0, y2));
                ctx.BezierTo(new Point(x0, y1), new Point(x1, y0), new Point(x2, y0));
                ctx.EndFigure(true);
            }

            PlatformImpl = impl;
        }
示例#15
0
 private void Train(Vector[] inputs, bool[] outputs)
 {
     numberOfTrainingItems.ObservedValue = inputs.Length;
     trainingInputs.ObservedValue = inputs;
     trainingOutputs.ObservedValue = outputs;
     weightsPosteriorDistribution.ObservedValue = trainingEngine.Infer<VectorGaussian>(testingOutputs);
 }
示例#16
0
        protected override Size MeasureOverride(Size availableSize)
        {
            double width = 0;
            double height = 0;
            Vector scale = new Vector();

            if (this.Source != null)
            {
                width = this.Source.PixelWidth;
                height = this.Source.PixelHeight;

                if (this.Width > 0)
                {
                    availableSize = new Size(this.Width, availableSize.Height);
                }

                if (this.Height > 0)
                {
                    availableSize = new Size(availableSize.Width, this.Height);
                }

                scale = CalculateScaling(availableSize, new Size(width, height), this.Stretch);
            }

            return new Size(width * scale.X, height * scale.Y);
        }
        /// <summary>
        /// Computes the maximum descent possible from the vector x in the direction dir.
        /// </summary>
        /// <param name="func">Function to find it the greatest descent possible in the given direction.</param>
        /// <param name="x">Current vector of the minimization Quasi-Newton algorithm.</param>
        /// <param name="dir">Descent direction vector for the current vector.</param>
        /// <returns>The value of the maximum descent possible.</returns>
        public static double Wolfe(CompiledFunc func, Vector x, Vector dir)
        {
            double a = 0;
            double ai = 1;
            double fPrev = 0, fCurr = 0, diff = 0;

            double fZero = func.Eval(x);
            var normDir = dir.Normalize();

            double diffZero = (func.Differentiate(x)*normDir).Sum();

            while(ai < MaxAlpha)
            {
                fPrev = func.Eval(x + a*dir);
                fCurr = func.Eval(x + ai*dir);

                if (fCurr > fZero + C1*ai*diffZero || (fCurr > fPrev && ai > 1))
                    return Zoom(func, x, dir, a, ai, fZero, diffZero);

                diff = (func.Differentiate(x + ai*dir)*normDir).Sum();

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

                if (diff >= 0)
                    return Zoom(func, x, dir, ai, a, fZero, diffZero);

                a = ai;
                ai *= 1.5;
            }

            return ai;
        }
        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;
        }
示例#19
0
        public override double integratedVariance(int i, int j, double u, Vector x)
        {
            double a = arguments_[0].value(0.0);
            double b = arguments_[1].value(0.0);
            double c = arguments_[2].value(0.0);
            double d = arguments_[3].value(0.0);

            double T = fixingTimes_[i];
            double S = fixingTimes_[j];

            double k1 = Math.Exp(b*u);
            double k2 = Math.Exp(b*S);
            double k3 = Math.Exp(b * T);

            return (a*a*(-1 - 2*b*b*S*T - b*(S + T)
                     + k1*k1*(1 + b*(S + T - 2*u) + 2*b*b*(S - u)*(T - u)))
                    + 2*b*b*(2*c*d*(k2 + k3)*(k1 - 1)
                         +d*d*(k1*k1 - 1)+2*b*c*c*k2*k3*u)
                    + 2*a*b*(d*(-1 - b*(S + T) + k1*k1*(1 + b*(S + T - 2*u)))
                         -2*c*(k3*(1 + b*S) + k2*(1 + b*T)
                               - k1*k3*(1 + b*(S - u))
                               - k1*k2*(1 + b*(T - u)))
                            )
                    ) / (4*b*b*b*k2*k3);
        }
示例#20
0
	/**
	 * Controle la balle avec des deplacements gauche,
	 * droite et profondeur
	 * return listFloat
	 */
	ArrayList StyleJeuSimple(){
		Frame frame = controller.Frame();
		Hand hand = frame.Hands.Rightmost;
		handPosition = hand.PalmPosition;
		ArrayList listFloat = new ArrayList();
		float moveSimpleX = 0;
		float moveSimpleZ = 0;

		export.AddRow();
		export["Time in ms"] = Time.timeSinceLevelLoad;
		export["Pos hand in x"] = handPosition.x;
		export["Pos hand in z"] = handPosition.z;
		
		if(hand.IsValid){
			if(moveSimpleX == (handPosition.x)/10 * Time.deltaTime * 3){
				moveSimpleX = 0;
			}else{
				moveSimpleX = (handPosition.x)/10 * Time.deltaTime * 3;
			}
			
			if (moveSimpleZ == (-handPosition.z) / 10 * Time.deltaTime * 3){
				moveSimpleZ = 0;
			}else{
				moveSimpleZ = (-handPosition.z) / 10 * Time.deltaTime * 3;
			}
		}
		listFloat.Add(moveSimpleX);
		listFloat.Add(moveSimpleZ);
		
		return listFloat;
	}
        /// <summary>
        /// Initialize the algorithm with points and initial clusters
        /// </summary>
        /// <param name="points">The list of Points objects</param>
        /// <param name="clusters">The list of Clusters objects</param>
        /// <param name="fuzzy">The fuzzyness factor to be used, constant</param>
        /// <param name="numCluster">The number of clusters requested by the user from the GUI</param>
        public FuzzyCMeans(Vector<double> points, double fuzzy, int numCluster)
        {
            Clusters = new ClusterCentroid[numCluster];
            this.numCluster = numCluster;
            featureVector = points;

            U = new double[this.featureVector.Count, numCluster];
            this.Fuzzyness = fuzzy;

            //Create random points to use a the cluster centroids
            /*
            Random random = new Random();
            for (int i = 0; i < numCluster; i++)
            {
                int randomNumber1 = random.Next(featureVector.Count);

                Clusters.Add(new ClusterCentroid(randomNumber1, featureVector[randomNumber1]));
            }*/

            InitClusterUsingKPlusPlus();

            InitU();

            this.RecalculateClusterMembershipValues();
        }
示例#22
0
 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);
 }
示例#23
0
 public override float Pdf(ref Vector wo, ref Vector wi)
 {
     Vector H = (wo + wi).Normalize();
     float costheta = Math.Abs(H.z);
     float blinn_pdf = ((exponent + 2f) * (float)Math.Pow(costheta, exponent)) / (2f * MathLab.M_PI * 4f * (wo & H));
     return blinn_pdf;
 }
 /// <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;
 }
示例#25
0
文件: Line.cs 项目: Supitto/Metria
        public Line(Point P, Point Q)
        {
            if(P.X == Q.X) // se for vertical
            {
                _a = new Point((P.Y < Q.Y) ? P : Q);
                _b = new Point((P.Y < Q.Y) ? Q : P);
                _center = new Point(_a.X, 0);
                _radius = 0;
                _alfa = new Point (Center.X,0);
                _beta = new Point (Center.X,-1);
                _director = new Vector(new Point(0,1));

            }
            else
            {
                _a = new Point((P.X < Q.X) ? P : Q);
                _b = new Point((P.X < Q.X) ? Q : P);
                if (A.Y == B.Y)
                    _center = new Point((A.X + B.X) / 2, 0);
                else
                    _center = new Point(((A.X * A.X) - (B.X * B.X) + (A.Y * A.Y) * (B.Y * B.Y)) / (2 * (A.X - B.X)), 0);
                _radius = (float)A.EuclidianDistance(Center);
                _alfa = new Point(Center.X-Radius, 0);
                _beta = new Point(Center.X+Radius, 0);
                _director = new Vector(Center, A).Normal;

            }
        }
示例#26
0
 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);
 }
示例#27
0
 public void Move(Vector offset)
 {
     foreach(Node node in Nodes) {
         node.X += offset.X;
         node.Y += offset.Y;
     }
 }
示例#28
0
    private static int VectorIntEquals()
    {
        const int Pass = 100;
        const int Fail = -1;

        Vector<int> A = new Vector<int>(3);
        Vector<int> B = new Vector<int>(3);
        Vector<int> C = new Vector<int>(5);

        bool result = A.Equals(B);
        if (!result)
        {
            return Fail;
        }

        result = A.Equals(C);
        if (result)
        {
            return Fail;
        }

        if (A.Equals(Vector<int>.Zero))
        {
            return Fail;
        }

        if (!Vector<int>.Zero.Equals(Vector<int>.Zero))
        {
            return Fail;
        }

        return Pass;
    }
示例#29
0
文件: Task.cs 项目: RCnowak/diploma
        // 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);
        }
示例#30
0
        public override void Sample_f(ref Vector wo, ref Normal N, ref Normal shadeN, ref RgbSpectrum in_f, float u0, float u1, float u2, ref SurfaceTextureData surfaceData, out BsdfSampleData result)
        {
            result.Lambda = 0f;

            Vector dir = MC.CosineSampleHemisphere(u0, u1);
            result.Pdf = dir.z * MathLab.INVPI;
            result.Type = BrdfType.Diffuse | BrdfType.Refractive;

            Vector v1, v2;
            Normal n = -N;
            Vector.CoordinateSystem(ref n, out v1, out v2);

            dir = new Vector(
                v1.x * dir.x + v2.x * dir.y + n.x * dir.z,
                v1.y * dir.x + v2.y * dir.y + n.y * dir.z,
                v1.z * dir.x + v2.z * dir.y + n.z * dir.z);

            var wi = dir;

            float dp = (Normal.AbsDot(ref n, ref wi));
            // Using 0.01 instead of 0.0 to cut down fireflies
            if (dp <= 0.0001f)
            {
                result.Pdf /= 1000f;
                //    return new RgbSpectrum(0f);
            }
            else
            {
                result.Pdf /= dp;
            }

            result.F=  KdOverPI;
            result.Wi = wi;
        }
示例#31
0
 /// <inheritdoc />
 public override Tuple <double, double> Predict(Vector y, bool p)
 {
     throw new NotImplementedException();
 }
示例#32
0
 public void Test(ref SphereWide a, ref SphereWide b, ref Vector <float> speculativeMargin, ref Vector3Wide offsetB, ref QuaternionWide orientationB, int pairCount, out Convex1ContactManifoldWide manifold)
 {
     throw new NotImplementedException();
 }