Class: Geom::Triangle
- Inherits:
-
Object
- Object
- Geom::Triangle
- Defined in:
- lib/geom/triangle.rb
Instance Attribute Summary collapse
-
#normal ⇒ Object
Returns the value of attribute normal.
-
#texcoord ⇒ Object
Returns the value of attribute texcoord.
-
#vertices ⇒ Object
Returns the value of attribute vertices.
Instance Method Summary collapse
- #clone ⇒ Object
- #flip_normal ⇒ Object
-
#initialize(vertices, texcoord = nil, normal = nil) ⇒ Triangle
constructor
A new instance of Triangle.
Constructor Details
#initialize(vertices, texcoord = nil, normal = nil) ⇒ Triangle
Returns a new instance of Triangle.
6 7 8 9 10 11 12 13 14 |
# File 'lib/geom/triangle.rb', line 6 def initialize(vertices,texcoord=nil,normal=nil) unless vertices.length == 3 raise "Triangle must consist of exactly 3 vertices" end @normal = normal || Number3D.new @vertices = vertices @texcoord = texcoord create_normal end |
Instance Attribute Details
#normal ⇒ Object
Returns the value of attribute normal.
4 5 6 |
# File 'lib/geom/triangle.rb', line 4 def normal @normal end |
#texcoord ⇒ Object
Returns the value of attribute texcoord.
4 5 6 |
# File 'lib/geom/triangle.rb', line 4 def texcoord @texcoord end |
#vertices ⇒ Object
Returns the value of attribute vertices.
4 5 6 |
# File 'lib/geom/triangle.rb', line 4 def vertices @vertices end |
Instance Method Details
#clone ⇒ Object
22 23 24 |
# File 'lib/geom/triangle.rb', line 22 def clone Triangle.new(@vertices.collect{|v| v.clone},@texcoord.collect{|uv| uv.clone}) end |
#flip_normal ⇒ Object
16 17 18 19 20 |
# File 'lib/geom/triangle.rb', line 16 def flip_normal @normal.x = -@normal.x @normal.y = -@normal.y @normal.z = -@normal.z end |