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


C# Vector.Cross方法代码示例

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


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

示例1: CalculateNormal

	/**
	 * CalculateNormal
	 */
	private void CalculateNormal()
	{
		Vector ba = new Vector();
		Vector bc = new Vector();

		Normal = new Vector();
		ba.Sub(Vertices[0], Vertices[1]);
		bc.Sub(Vertices[2], Vertices[1]);
		Normal.Cross(bc, ba);
		Normal.Normalize();
	}
开发者ID:lewurm,项目名称:benchmarker,代码行数:14,代码来源:PolyTypeObj.cs

示例2: 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,代码行数:33,代码来源:TriangleObj.cs

示例3: ByOriginVectors

        /// <summary>
        /// Constructs a CoordinateSystem from an origin point, and two axis 
        /// vectors as input. The 'sheared' flag is used to determine if the 
        /// axes stay sheared or orthogonal to each other and 'normalized' flag 
        /// to normalize axes or not.
        /// </summary>
        /// <param name="origin">the origin of the CoordinateSystem to be constructed</param>
        /// <param name="xAxis">the x-axis of the CoordinateSystem to be constructed</param>
        /// <param name="yAxis">the y-axis of the CoordinateSystem to be constructed</param>
        /// <param name="isSheared">The 'sheared' flag is used to determine if the 
        /// axes stay sheared or orthogonal to each other.</param>
        /// <param name="isNormalized">'normalized' flag is used to determine if axes 
        /// should be normalized or not</param>
        /// <returns></returns>
        public static CoordinateSystem ByOriginVectors(Point origin, Vector xAxis, Vector yAxis, bool isSheared, bool isNormalized)
        {
            if (xAxis == null)
                throw new System.ArgumentNullException("xAxis");
            else if (yAxis == null)
                throw new System.ArgumentNullException("yAxis");
            else if (xAxis.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "x axis"), "xAxis");
            else if (yAxis.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "y axis"), "yAxis");

            var zAxis = xAxis.Cross(yAxis);
            return ByOriginVectors(origin, xAxis, yAxis, zAxis, isSheared, isNormalized);
        }
开发者ID:samuto,项目名称:designscript,代码行数:28,代码来源:CoordinateSystem.cs

示例4: QuatMultiply

        static Quat QuatMultiply( Quat q0, Quat q1 )
        {
            Quat	q = new Quat();
            Vector	V0 = new Vector( q0.qv.x, q0.qv.y, q0.qv.z );
            Vector	V1 = new Vector( q1.qv.x, q1.qv.y, q1.qv.z );
            q.qs = q0.qs * q1.qs - V0.Dot( V1 );
            Vector	V = q0.qs * V1 + V0 * q1.qs + V0.Cross( V1 );
            q.qv.x = V.X;
            q.qv.y = V.Y;
            q.qv.z = V.Z;

            return q;
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:13,代码来源:Scene.cs

示例5: GetCSAtParameters

        internal CoordinateSystem GetCSAtParameters(double u, double v)
        {
            bool uchange = GeometryExtension.ClipParamRange(ref u);
            bool vchange = GeometryExtension.ClipParamRange(ref v);
            // TO DO - throw a warning each time a condition above is satisfied.
            //throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "u or v parameter", "Surface.PointAtUVParameters"));

            IPointEntity pos = SurfaceEntity.PointAtParameter(u, v);
            Point origin = pos.ToPoint(false, null);
            Vector xAxis = new Vector(SurfaceEntity.TangentAtUParameter(u, v));
            Vector yAxis = new Vector(SurfaceEntity.TangentAtVParameter(u, v));
            Vector zAxis = xAxis.Cross(yAxis);

            return CoordinateSystem.ByOriginVectors(origin, xAxis, yAxis, zAxis, false, true, false);
        }
开发者ID:samuto,项目名称:designscript,代码行数:15,代码来源:Surface.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


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