Пример #1
0
 public override void intersect(ref HitRecord hit, RenderContext rc, Ray ray)
 {
     float num = Vector.dot( -this.norm, ray.p() - this.point );
       float denom = Vector.dot( this.norm, ray.d() );
       float t = num/denom;
       if ( denom==0 || num==0 || t < 0 ) hit.hit( float.PositiveInfinity, this, this.material );
       else hit.hit( num/denom, this, this.material );
 }
Пример #2
0
        public override void intersect(ref HitRecord hit, RenderContext rc, Ray ray)
        {
            Vector dist = ray.p() - this.p;
            float b = Vector.dot(dist, ray.d());
            float c = Vector.dot(dist, dist) - this.r2();
            float d = b * b - c;
            float t = (d > 0) ? -b - (float)System.Math.Sqrt(d) : float.PositiveInfinity;

            hit.hit(t, this, this.material);
        }