lib/annlat/plot.rb
# sum of angles for interior point should be 2 * pi
sum of angles for interior point should be 2 * pi
sum of angles for interior point should be 2 * pi
def check_interior(polygon, point)
    sum = 0
    polygon.each_index do |i|
      next_i = i + 1
      next_i = 0 if next_i >= polygon.size
      sum += compute_angle(
        [polygon[i][0] - point[0],
         polygon[i][1] - point[1],
         polygon[i][2] - point[2]],
        [polygon[next_i][0] - point[0],
         polygon[next_i][1] - point[1],
         polygon[next_i][2] - point[2]],
      )
    end
    (sum >= 2*3.1415926 and sum <= 2*3.1415927) or
      check_border(polygon, point)
  end
def check_interior ( polygon , point ) sum = 0 polygon . each_index do | i | next_i = i + 1 next_i = 0 if next_i >= polygon . size sum += compute_angle ( [ polygon [ i ] [ 0 ] - point [ 0 ] , polygon [ i ] [ 1 ] - point [ 1 ] , polygon [ i ] [ 2 ] - point [ 2 ] ] , [ polygon [ next_i ] [ 0 ] - point [ 0 ] , polygon [ next_i ] [ 1 ] - point [ 1 ] , polygon [ next_i ] [ 2 ] - point [ 2 ] ] , ) end ( sum >= 2 * 3.1415926 and sum <= 2 * 3.1415927 ) or check_border ( polygon , point ) end
sum of angles for interior point should be 2 * pi
sum of angles for interior point should be 2 * pi
polygon
point