Pete Yandell wrote:
>     # Turn to face the given point.
>     def toward(pt)
>       raise ArgumentError unless is_point?(pt)
>       @heading = (atan2(pt.first - @xy.first, pt.last  - @xy.last) /
> DEG) % 360
>     end
> 

What is the correct behavior if calling toward(pt) and @xy == pt. In 
this case, atan2 returns 0.0 (North in turtle). This means that setting 
the turtle to point to where it already is makes it always face North, 
which seems wrong. I would think that this should be a no-op (heading 
does not change).

irb(main):004:0> Math.atan2(0,0)
=> 0.0

Try this test case.

  def test_toward
    east = [100, 0]
    @turtle.face east
    assert_equal(90, @turtle.heading.round)
    assert_nothing_raised { @turtle.face [0, 0] }
    assert_equal(90, @turtle.heading.round)
  end

-- 
Posted via http://www.ruby-forum.com/.