class WindingPolygon::Point
Attributes
x[RW]
y[RW]
Public Class Methods
new(x,y)
click to toggle source
# File lib/winding-polygon/point.rb, line 7 def initialize(x,y) @x=x @y=y end
Public Instance Methods
<(other_point)
click to toggle source
# File lib/winding-polygon/point.rb, line 45 def < (other_point) return true if @x < other_point.x return true if @x == other_point.x && @y < other_point.y return false end
<=>(other_point)
click to toggle source
# File lib/winding-polygon/point.rb, line 27 def <=> other_point raise Exception.new("Self is x=#{@x},y=#{@y}, the other_point is nil") if other_point.nil? # x-coord first return 1 if @x > other_point.x return -1 if @x < other_point.x # y-coord second return 1 if @y > other_point.y return -1 if @y < other_point.y # they are the same point return 0 end
==(other_point)
click to toggle source
# File lib/winding-polygon/point.rb, line 41 def == (other_point) @x==other_point.x && @y==other_point.y end
>(other_point)
click to toggle source
# File lib/winding-polygon/point.rb, line 51 def > (other_point) return true if @x > other_point.x return true if @x == other_point.x && @y > other_point.y return false end
compare(other_point)
click to toggle source
Determines the xy lexicographical order of two points
# File lib/winding-polygon/point.rb, line 13 def compare other_point raise Exception.new("Self is x=#{@x},y=#{@y}, the other_point is nil") if other_point.nil? # x-coord first return 1 if @x > other_point.x return -1 if @x < other_point.x # y-coord second return 1 if @y > other_point.y return -1 if @y < other_point.y # they are the same point return 0 end
is_left(p0, p1)
click to toggle source
tests if point is Left|On|Right of the line P0 to P1.
returns:
>0 for left of the line 0 for on the line <0 for right of the line
# File lib/winding-polygon/point.rb, line 63 def is_left p0, p1 return (p1.x - p0.x) * (@y - p0.y) - (@x - p0.x) * (p1.y - p0.y) end