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


C# Vector.Scale方法代码示例

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


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

示例1: DrawLine

        protected void DrawLine(IDrawContext drawContext, DrawingLayer drawingLayer, Vector fromVector, Vector toVector, int width, Color color)
        {
            var finalFrom = fromVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var finalTo = toVector
                .Scale(drawContext.Camera.ZoomFactor)
                .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var param = new DrawLineParams
            {
                VectorFrom = finalFrom,
                VectorTo = finalTo,
                Width = width * drawContext.Camera.ZoomFactor,
                Color = color
            };

            drawContext.DrawLine(param);
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:20,代码来源:DrawingElementBase.cs

示例2: ToOriginCenteredLine

 public static Line ToOriginCenteredLine(Point origin, Vector axis)
 {
     return Line.ByStartPointEndPoint(origin.Add(axis.Scale(-axisScaleFactor)),
         origin.Add(axis.Scale(axisScaleFactor)));
 }
开发者ID:mikeyforrest,项目名称:Dynamo,代码行数:5,代码来源:MousePointManipulator.cs

示例3: DrawAxis

        /// <summary>
        /// Draws axis as 3D arrow based on scale factor.
        /// </summary>
        /// <param name="package"></param>
        /// <param name="axis"></param>
        private void DrawAxis(ref IRenderPackage package, Vector axis)
        {
            var axisType = GetAlignedAxis(axis);
            package.Description = string.Format("{0}_{1}_{2}", RenderDescriptions.ManipulatorAxis, Name, axisType.ToString());

            using (var axisEnd = Origin.Add(axis.Scale(scale)))
            {
                var color = GetAxisColor(axisType);
                package.AddLineStripVertexCount(2);
                package.AddLineStripVertexColor(color.R, color.G, color.B, color.A);
                package.AddLineStripVertex(Origin.X, Origin.Y, Origin.Z);
                package.AddLineStripVertexColor(color.R, color.G, color.B, color.A);
                package.AddLineStripVertex(axisEnd.X, axisEnd.Y, axisEnd.Z);
            }
        }
开发者ID:mikeyforrest,项目名称:Dynamo,代码行数:20,代码来源:TranslationGizmo.cs

示例4: PrecisionConditional

		/// <summary>
		/// Gibbs message to 'precision'
		/// </summary>
		/// <param name="Sample">Constant value for 'sample'.</param>
		/// <param name="Mean">Constant value for 'mean'.</param>
		/// <param name="result">Modified to contain the outgoing message</param>
		/// <returns><paramref name="result"/></returns>
		/// <remarks><para>
		/// The outgoing message is the factor viewed as a function of 'precision' conditioned on the given values.
		/// </para></remarks>
		public static Wishart PrecisionConditional(Vector Sample, Vector Mean, Wishart result, Vector diff)
		{
			if (result == default(Wishart)) result = new Wishart(Sample.Count);
			diff.SetToDifference(Sample, Mean);
			const double SQRT_HALF = 0.70710678118654752440084436210485;
			diff.Scale(SQRT_HALF);
			result.Rate.SetToOuter(diff, diff);
			result.Shape = 0.5 * (result.Dimension + 2);
			return result;
		}
开发者ID:dtrckd,项目名称:Mixed-Membership-Stochastic-Blockmodel,代码行数:20,代码来源:VectorGaussianOp.cs

示例5: BAverageLogarithm

		public static Gamma BAverageLogarithm([SkipIfUniform] Gaussian Product, [Proper] Gaussian A, [Proper] Gamma B, Gamma result)
		{
			if (B.IsPointMass) return Gamma.Uniform();
			if (Product.IsPointMass) return BAverageLogarithm(Product.Point, A);
			if (!B.IsProper()) throw new ImproperMessageException(B);
			// catch uniform case to avoid 0*Inf
			if (Product.IsUniform()) return Gamma.Uniform();
			double rateb = B.Rate;
			double shapeb = B.Shape;
			double ma, va;
			A.GetMeanAndVariance(out ma, out va);

			// encourage resulting (shape,rate) to be close to B
			// unfortunately, this doesn't force rate>0 - only scales result
			double penalty = 1;
			Vector Bvec = new Vector(2);
			Bvec[0] = result.Shape-1;
			Bvec[1] = result.Rate;
			Vector g = GradientVector(Product, A, B);
			Matrix W = WeightMatrix(B);
			W.SetToTranspose(W);
			PositiveDefiniteMatrix W2 = W.Outer();
			//W2.SetToSum(W2, PositiveDefiniteMatrix.IdentityScaledBy(W2.Rows, penalty));
			Vector Wg = W*g;
			Bvec = W2*Bvec;
			Bvec.SetToSum(1.0, Wg, penalty, Bvec);
			return Gamma.FromShapeAndRate(Bvec[0]/W2[0, 0] + 1, 0.0);

			Bvec.PredivideBy(W2);
			Bvec.Scale(1.0/(1+penalty));
			return Gamma.FromShapeAndRate(Bvec[0]+1, Bvec[1]);
		}
开发者ID:dtrckd,项目名称:Mixed-Membership-Stochastic-Blockmodel,代码行数:32,代码来源:ProductGaussianGamma.cs

示例6: RenderScene

	/**
	 * RenderScene
	 */
	public void RenderScene(Canvas canvas, int width, int section, int nsections)
	{
		Vector view = camera.GetViewDir();
		Vector up = camera.GetOrthoUp();
		Vector plane = new Vector();
		Vector horIncr = new Vector();
		Vector vertIncr = new Vector();
		double ylen = camera.GetFocalDist() * (double)Math.Tan(0.5f * camera.GetFOV());
		double xlen = ylen * canvas.GetWidth() / canvas.GetHeight();
		Point upleft = new Point();
		Point upright = new Point();
		Point lowleft = new Point();
		Point basepoint = new Point();
		Point current;
		Ray eyeRay = new Ray();
		int ypixel, xpixel;

		RayID = 1;
		plane.Cross(view, up);
		view.Scale(camera.GetFocalDist());
		up.Scale(ylen);
		plane.Scale(-xlen);
		upleft.FindCorner(view, up, plane, camera.GetPosition());
		plane.Negate();
		upright.FindCorner(view, up, plane, camera.GetPosition());
		up.Negate();
		plane.Negate();
		lowleft.FindCorner(view, up, plane, camera.GetPosition());
		horIncr.Sub(upright, upleft);
		horIncr.Scale(horIncr.Length() / ((double)canvas.GetWidth()));
		vertIncr.Sub(lowleft, upleft);
		vertIncr.Scale(vertIncr.Length() / ((double)canvas.GetHeight()));
		basepoint.Set(upleft.GetX() + 0.5f * (horIncr.GetX() + vertIncr.GetX()), upleft.GetY() + 0.5f * (horIncr.GetY() + vertIncr.GetY()),
			upleft.GetZ() + 0.5f * (horIncr.GetZ() + vertIncr.GetZ()));
		eyeRay.SetOrigin(camera.GetPosition());

		int xstart = section * width / nsections;
		int xend = xstart + width / nsections;

		Console.WriteLine("+" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());

		for(ypixel = 0; ypixel < canvas.GetHeight(); ypixel++)
		{
			current = new Point(basepoint);
			for(xpixel = 0; xpixel < canvas.GetWidth(); xpixel++)
			{
				if(xpixel >= xstart && xpixel < xend)
				{
					Color color = new Color(0.0f, 0.0f, 0.0f);
					eyeRay.GetDirection().Sub(current, eyeRay.GetOrigin());
					eyeRay.GetDirection().Normalize();
					eyeRay.SetID(RayID);
					this.RayID = this.RayID + 1;
					Shade(octree, eyeRay, color, 1.0f, 0, 0);
					canvas.Write(Brightness, xpixel, ypixel, color);
				}
				current.Add(horIncr);
			}
			basepoint.Add(vertIncr);
		}
		Console.WriteLine("-" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
	}
开发者ID:lewurm,项目名称:benchmarker,代码行数:65,代码来源:Scene.cs

示例7: TriangleObj

	/**
	 * TriangleObj
	 *
	 * @param objmaterial
	 * @param newobjID
	 * @param numverts
	 * @param vertices
	 * @param MaxX
	 * @param MinX
	 * @param MaxY
	 * @param MinY
	 * @param MaxZ
	 * @param MinZ
	 */
	public TriangleObj(Material objmaterial, int newobjID, int numverts, Point[] vertices, Point max, Point min)
		: base(objmaterial, newobjID, numverts, vertices, max, min)
	{
		Vector[] temp = new Vector[3];
		for(int i = 0; i < 3; i++)
		{
			temp[i] = new Vector(vertices[i].GetX(), vertices[i].GetY(), vertices[i].GetZ());
		}

		S1 = new Vector();
		S2 = new Vector();
		S3 = new Vector();
		S1.Cross(temp[1], temp[2]);
		S2.Cross(temp[2], temp[0]);
		S3.Cross(temp[0], temp[1]);
		double delta = 1.0f / S1.Dot(temp[0]);
		S1.Scale(delta * S1.Length());
		S2.Scale(delta * S2.Length());
		S3.Scale(delta * S3.Length());
	}
开发者ID:lewurm,项目名称:benchmarker,代码行数:34,代码来源:TriangleObj.cs

示例8: ByPointVectorDistance

        /// <summary>
        /// Create a Reference Point Element offset from a point along a vector
        /// </summary>
        /// <param name="basePoint"></param>
        /// <param name="direction"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static ReferencePoint ByPointVectorDistance(Point basePoint, Vector direction, double distance)
        {
            if (!Document.IsFamilyDocument)
            {
                throw new Exception("ReferencePoint Elements can only be created in a Family Document");
            }

            if (basePoint == null)
            {
                throw new ArgumentNullException("basePoint");
            }

            if (direction == null)
            {
                throw new ArgumentNullException("direction");
            }

            var pt = (Point) basePoint.Translate(direction.Scale(distance));

            return new ReferencePoint(pt.ToXyz());

        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:29,代码来源:ReferencePoint.cs


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