lib/mageo/triangle.rb in mageo-0.0.5 vs lib/mageo/triangle.rb in mageo-0.1.0

- old
+ new

@@ -20,20 +20,22 @@ # or Mageo::Vector3D class instance, which have [] and map methods. #当面は Array を前提とする。 #座標が整数で入っていたとしても内部的には Float に変換して使用する。 #3点が1直線上に並んでいて三角形を囲まない場合は #例外 Mageo::Triangle::LinearException を投げる。 - def initialize( vertices ) - raise InitializeError unless vertices.methods.include?( :size ) - raise InitializeError if vertices.size != 3 - vertices.each do |pos| - raise InitializeError if pos.size != 3 - raise InitializeError unless pos.methods.include?( :[] ) - raise InitializeError unless pos.methods.include?( :map ) - end - @vertices = vertices.map do |pos| - ( pos.map { |i| i.to_f }) . to_v3d - end + #def initialize( vertices ) + def initialize( v0, v1, v2 ) + #raise InitializeError unless vertices.methods.include?( :size ) + #raise InitializeError if vertices.size != 3 + #vertices.each do |pos| + # raise InitializeError if pos.size != 3 + # raise InitializeError unless pos.methods.include?( :[] ) + # raise InitializeError unless pos.methods.include?( :map ) + #end + #@vertices = vertices.map do |pos| + # ( pos.map { |i| i.to_f }) . to_v3d + #end + @vertices = [v0.to_v3d, v1.to_v3d, v2.to_v3d] #Checking on linear. edge1 = @vertices[1] - @vertices[0] edge2 = @vertices[2] - @vertices[0] if ( Mageo::Vector3D[0.0, 0.0, 0.0] == Mageo::Vector3D.vector_product( edge1, edge2 ))