lib/geometry/polygon.rb in geometry-6.2 vs lib/geometry/polygon.rb in geometry-6.3
- old
+ new
@@ -16,15 +16,15 @@
=end
class Polygon < Polyline
# Construct a new Polygon from Points and/or Edges
- # The constructor will try to convert all of its arguments into Points and
- # Edges. Then successive Points will be collpased into Edges. Successive
- # Edges that share a common vertex will be added to the new Polygon. If
- # there's a gap between Edges it will be automatically filled with a new
- # Edge. The resulting Polygon will then be closed if it isn't already.
+ # The constructor will try to convert all of its arguments into {Points} and
+ # {Edges}. Then successive {Points} will be collpased into {Edges}. Successive
+ # {Edges} that share a common vertex will be added to the new {Polygon}. If
+ # there's a gap between {Edges} it will be automatically filled with a new
+ # {Edge}. The resulting Polygon will then be closed, if it isn't already.
# @overload initialize(Edge, Edge, ...)
# @return [Polygon]
# @overload initialize(Point, Point, ...)
# @return [Polygon]
def initialize(*args)
@@ -114,10 +114,10 @@
intersection = a.intersection(b)
if intersection === true
if (a.first == b.first) and (a.last == b.last) # Equal edges
elsif (a.first == b.last) and (a.last == b.first) # Ignore equal but opposite edges
else
- if a.vector.normalize == b.vector.normalize # Same direction?
+ if a.direction == b.direction # Same direction?
offsetA += 1 if ringA.insert_boundary(indexA + 1 + offsetA, b.first)
offsetB += 1 if ringB.insert_boundary(indexB + 1 + offsetB, a.last)
else # Opposite direction
offsetA += 1 if ringA.insert_boundary(indexA + 1 + offsetA, b.last)
offsetB += 1 if ringB.insert_boundary(indexB + 1 + offsetB, a.first)