Talk:Sutherland-Hodgman polygon clipping

From Rosetta Code
Revision as of 19:31, 19 August 2011 by rosettacode>Kernigh (→‎Ruby: new section)

Draft Task Status

Still needs description of the task. –Donal Fellows 11:15, 23 March 2010 (UTC)

OK, it's now good enough to be a task. Further cleanup can be done within that framework. –Donal Fellows 15:25, 23 March 2010 (UTC)

Winding

Implementations probably should be required to test if the clipper is winding clockwise or not. Some of the current code crash if the rectangle is reversed. Testing direction of a convex poly is pretty easy anyway, just checking any one vertex should be enough. --Ledrug 01:23, 7 July 2011 (UTC)

Ruby

With Ruby 1.9, a block parameter must be a local variable.

$ ruby scratch.rb                                                              
scratch.rb:22: formal argument cannot be an instance variable
    clipPolygon.each do |@cp2| # WP clipEdge is cp1,cp2 here
                             ^
scratch.rb:26: formal argument cannot be an instance variable
      inputList.each do |@e|
                           ^

My change to the Ruby code fixes it for Ruby 1.9 but keeps it working with Ruby 1.8. --Kernigh 19:31, 19 August 2011 (UTC)