Talk:Sutherland-Hodgman polygon clipping: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎Winding: new section)
(→‎Ruby: new section)
Line 6: Line 6:


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. --[[User:Ledrug|Ledrug]] 01:23, 7 July 2011 (UTC)
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. --[[User:Ledrug|Ledrug]] 01:23, 7 July 2011 (UTC)

== Ruby ==

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

<pre>$ 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|
^</pre>

[http://rosettacode.org/mw/index.php?title=Sutherland-Hodgman_polygon_clipping&diff=118024&oldid=118006 My change to the Ruby code] fixes it for Ruby 1.9 but keeps it working with Ruby 1.8. --[[User:Kernigh|Kernigh]] 19:31, 19 August 2011 (UTC)

Revision as of 19:31, 19 August 2011

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)