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


C# Ray.Apply方法代码示例

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


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

示例1: IntersectP

        public override bool IntersectP(Ray r)
        {
            var ray = new Ray ();
            this.WorldToObject.Apply (r, ref ray);

            if (Math.Abs (ray.Direction.z) < 1e-7) return false;
            var thit = (height - ray.Origin.z) / ray.Direction.z;
            if (thit < ray.MinT || thit > ray.MaxT)
                return false;

            var phit = ray.Apply (thit);
            var dist2 = phit.x * phit.x + phit.y * phit.y;
            if (dist2 > radius * radius || dist2 < innerRadius * innerRadius)
                return false;

            var phi = Math.Atan2 (phit.y, phit.x);
            if (phi < 0) phi += 2.0 * Math.PI;
            if (phi > phiMax)
                return false;
            return true;
        }
开发者ID:Kintaro,项目名称:Art,代码行数:21,代码来源:Disk.cs

示例2: Intersect

        public override bool Intersect(Ray r, out double tHit, out double rayEpsilon, DifferentialGeometry dg)
        {
            tHit = 0.0;
            rayEpsilon = 0.0;

            var ray = new Ray ();
            this.WorldToObject.Apply (r, ref ray);

            if (Math.Abs (ray.Direction.z) < 1e-7) return false;
            var thit = (height - ray.Origin.z) / ray.Direction.z;
            if (thit < ray.MinT || thit > ray.MaxT)
                return false;

            var phit = ray.Apply (thit);
            var dist2 = phit.x * phit.x + phit.y * phit.y;
            if (dist2 > radius * radius || dist2 < innerRadius * innerRadius)
                return false;

            var phi = Math.Atan2 (phit.y, phit.x);
            if (phi < 0) phi += 2.0 * Math.PI;
            if (phi > phiMax)
                return false;

            var u = phi / phiMax;
            var oneMinusV = ((Math.Sqrt (dist2) - innerRadius) /
                               (radius - innerRadius));
            var invOneMinusV = (oneMinusV > 0.0) ? (1.0 / oneMinusV) : 0.0;
            var v = 1.0 - oneMinusV;
            var dpdu = new Vector (-phiMax * phit.y, phiMax * phit.x, 0.0);
            var dpdv = new Vector (-phit.x * invOneMinusV, -phit.y * invOneMinusV, 0.0);
            dpdu *= phiMax * Util.InvTwoPI;
            dpdv *= (radius - innerRadius) / radius;
            var dndu = new Normal (0, 0, 0);
            var dndv = new Normal (0, 0, 0);

            var o2w = new Transform (this.ObjectToWorld);
            dg = new DifferentialGeometry (o2w.Apply (phit), null, null, o2w.Apply (dndu), o2w.Apply (dndv), u, v, this);

            tHit = thit;
            rayEpsilon = 5e-4 * tHit;

            return true;
        }
开发者ID:Kintaro,项目名称:Art,代码行数:43,代码来源:Disk.cs

示例3: Pdf

		/// <summary>
		///		Computes the propability distribution function at the given point
		/// </summary>
		/// <param name="p">The point to check against</param>
		/// <param name="wi">The out vector</param>
		/// <returns>The propability distribution function</returns>
		public virtual double Pdf (Point p, Vector wi)
		{
			var dgLight = new DifferentialGeometry ();
			var ray = new Ray (p, wi, 1e-3);
			ray.Depth = -1;
			double thit, rayEpsilon;

			if (!this.Intersect (ray, out thit, out rayEpsilon, dgLight))
				return 0.0;

			var pdf = Util.DistanceSquared (p, ray.Apply (thit)) / (Util.AbsDot (dgLight.nn, -wi) * this.Area);

			if (double.IsInfinity (pdf))
				pdf = 0.0;
			return pdf;
		}
开发者ID:Kintaro,项目名称:Art,代码行数:22,代码来源:IShape.cs


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