Class: Face
- Inherits:
-
Object
- Object
- Face
- Defined in:
- lib/face.rb
Overview
Warning, documentation written in mathsspeak
Instance Method Summary collapse
-
#initialize(v, axis1, axis2) ⇒ Face
constructor
Represents a 2-dimensional tile with sides of unit length in 4-dimensional space V is a vector4 representing the position of the faces base vertex Axis1 and axis2 are the two canonical axis that the face is aligned with.
- #max_axis ⇒ Object
- #min_axis ⇒ Object
-
#pos ⇒ Object
Getters.
-
#tick(translation_matrix) ⇒ Object
One iteration of the system Position is multiplied by translation_matrix Faces are updated based on algorithm encoded here with switch statements.
Constructor Details
#initialize(v, axis1, axis2) ⇒ Face
Represents a 2-dimensional tile with sides of unit length in 4-dimensional space V is a vector4 representing the position of the faces base vertex Axis1 and axis2 are the two canonical axis that the face is aligned with
9 10 11 12 13 |
# File 'lib/face.rb', line 9 def initialize v, axis1, axis2 @pos = v @a_min = min(axis1, axis2) @a_max = max(axis1, axis2) end |
Instance Method Details
#max_axis ⇒ Object
79 80 81 |
# File 'lib/face.rb', line 79 def max_axis @a_max end |
#min_axis ⇒ Object
75 76 77 |
# File 'lib/face.rb', line 75 def min_axis @a_min end |
#pos ⇒ Object
Getters
71 72 73 |
# File 'lib/face.rb', line 71 def pos @pos end |
#tick(translation_matrix) ⇒ Object
One iteration of the system Position is multiplied by translation_matrix Faces are updated based on algorithm encoded here with switch statements
There are some cases where the face splits in two, so we return either a new face or nil
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/face.rb', line 22 def tick translation_matrix ret = nil @pos = translation_matrix * @pos case @a_min when 0 case @a_max when 1 @a_min = 1 @a_max = 2 when 2 @a_min = 1 @a_max = 3 when 3 @a_min = 0 @a_max = 1 ret = Face.new(@pos.clone, 1, 3) shunt_pos end when 1 case @a_max when 2 @a_min = 2 @a_max = 3 when 3 @a_min = 0 @a_max = 2 ret = Face.new(@pos.clone, 2, 3) shunt_pos end when 2 @a_min = 0 @a_max = 3 shunt_pos end return ret end |