class Plane

Public Class Methods

new(p, n) click to toggle source
# File typeprof-0.15.2/testbed/ao.rb, line 93
def initialize(p, n)
  @p = p
  @n = n
end

Public Instance Methods

intersect(ray, isect) click to toggle source
# File typeprof-0.15.2/testbed/ao.rb, line 98
def intersect(ray, isect)
  d = -@p.vdot(@n)
  v = ray.dir.vdot(@n)
  v0 = v
  if v < 0.0
    v0 = -v
  end
  if v0 < 1.0e-17
    return
  end

  t = -(ray.org.vdot(@n) + d) / v

  if t > 0.0 and t < isect.t
    isect.hit = true
    isect.t = t
    isect.n = @n
    isect.pl = Vec.new(ray.org.x + t * ray.dir.x,
                      ray.org.y + t * ray.dir.y,
                      ray.org.z + t * ray.dir.z)
  end
end