test/test_triangle.rb in gmath3D-0.2.3 vs test/test_triangle.rb in gmath3D-0.2.4
- old
+ new
@@ -297,6 +297,22 @@
point2 = Vector3.new(1,4,2)
assert( FiniteLine.new(point1, point2) == closest_line || FiniteLine.new(point2, point1) == closest_line)
assert_equal( nil, point_on_triangle )
assert_equal( nil, point_on_plane )
end
+
+ def test_angle
+ triangle1 = Triangle.new( Vector3.new(0,0,1), Vector3.new(Math.sqrt(3.0),0,1), Vector3.new(0,1,1))
+ triangle2 = Triangle.new( Vector3.new(1,0,0), Vector3.new(0,0,1), Vector3.new(1,1,1))
+
+ assert_equal(nil, triangle1.angle(-1))
+ assert_equal(nil, triangle1.angle(3))
+
+ assert_in_delta(90.0*Math::PI/180.0, triangle1.angle(0), triangle1.tolerance)
+ assert_in_delta(30.0*Math::PI/180.0, triangle1.angle(1), triangle1.tolerance)
+ assert_in_delta(60.0*Math::PI/180.0, triangle1.angle(2), triangle1.tolerance)
+
+ assert_in_delta(60.0*Math::PI/180.0, triangle2.angle(0), triangle1.tolerance)
+ assert_in_delta(60.0*Math::PI/180.0, triangle2.angle(1), triangle1.tolerance)
+ assert_in_delta(60.0*Math::PI/180.0, triangle2.angle(2), triangle1.tolerance)
+ end
end