Class: Wavefront::Triangle
- Inherits:
-
Object
- Object
- Wavefront::Triangle
- Defined in:
- lib/wavefront/triangle.rb
Instance Attribute Summary collapse
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
- #flip! ⇒ Object
-
#initialize(v) ⇒ Triangle
constructor
A new instance of Triangle.
Constructor Details
#initialize(v) ⇒ Triangle
Returns a new instance of Triangle.
5 6 7 8 |
# File 'lib/wavefront/triangle.rb', line 5 def initialize v raise "A triangle can only have three vertices!" if 3 != v.size @vertices = v end |
Instance Attribute Details
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
3 4 5 |
# File 'lib/wavefront/triangle.rb', line 3 def vertices @vertices end |
Instance Method Details
#flip! ⇒ Object
10 11 12 |
# File 'lib/wavefront/triangle.rb', line 10 def flip! vertices[1], vertices[2] = vertices[2], vertices[1] end |