Class: Ra::Surface

Inherits:
Object
  • Object
show all
Defined in:
lib/ra/surface.rb

Overview

A surface contains everything needed to apply lighting.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(eyev:, normalv:, reflectv:, shape:, point:) ⇒ Surface

Returns a new instance of Surface.

Parameters:

  • eyev (Vector)
  • normalv (Vector)
  • shape (Ra::Shape)
  • point (Vector)


30
31
32
33
34
35
36
# File 'lib/ra/surface.rb', line 30

def initialize(eyev:, normalv:, reflectv:, shape:, point:)
  @eyev = eyev
  @normalv = normalv.dot(eyev).negative? ? -normalv : +normalv
  @reflectv = reflectv
  @shape = shape
  @point = point
end

Instance Attribute Details

#eyevVector

Returns:

  • (Vector)


8
9
10
# File 'lib/ra/surface.rb', line 8

def eyev
  @eyev
end

#normalvVector

Returns:

  • (Vector)


12
13
14
# File 'lib/ra/surface.rb', line 12

def normalv
  @normalv
end

#pointVector

Returns:

  • (Vector)


24
25
26
# File 'lib/ra/surface.rb', line 24

def point
  @point
end

#reflectvVector

Returns:

  • (Vector)


16
17
18
# File 'lib/ra/surface.rb', line 16

def reflectv
  @reflectv
end

#shapeRa::Shape

Returns:



20
21
22
# File 'lib/ra/surface.rb', line 20

def shape
  @shape
end

Instance Method Details

#hpointVector

Returns:

  • (Vector)


39
40
41
# File 'lib/ra/surface.rb', line 39

def hpoint
  @hpoint ||= point + (normalv * EPSILON)
end