lib/ruby_on_rays/shapes/triangle.rb
# Returns true if there is an intersection between the ray and the triangle.
# @param ray [Ray3]
# @return [Boolean]
Returns true if there is an intersection between the ray and the triangle.
Returns true if there is an intersection between the ray and the triangle .
def intersection?(ray)
      s0 = ray.d.cross(@e1)
      divisor = s0.dot(@e0)
      return false if divisor == 0.0 
      inverse_divisor = 1.0 / divisor
      d = ray.o.sub(@a)
      b0 = d.dot(s0) * inverse_divisor
      return false if b0 < 0.0 || b0 > 1.0 
      s1 = d.cross(@e0)
      b1 = ray.d.dot(s1) * inverse_divisor
      return false if b1 < 0.0 || b0 + b1 > 1.0 
      true
    end
def intersection? ( ray ) s0 = ray . d . cross ( @e1 ) divisor = s0 . dot ( @e0 ) return false if divisor == 0.0 inverse_divisor = 1.0 / divisor d = ray . o . sub ( @a ) b0 = d . dot ( s0 ) * inverse_divisor return false if b0 < 0.0 || b0 > 1.0 s1 = d . cross ( @e0 ) b1 = ray . d . dot ( s1 ) * inverse_divisor return false if b1 < 0.0 || b0 + b1 > 1.0 true end
Returns true if there is an intersection between the ray and the triangle.
Returns true if there is an intersection between the ray and the triangle .
# Use MT triangle intersection algorithm: # Compute s0 # Not on plane. # Compute b0 (first barycentric coordinate) # Out of triangle. # Compute b1 (second barycentric coordinate) # Out of triangle.
None
Boolean
ray
<not_specific>
<not_specific>
None