Class: SimplifyRb::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/simplify_rb/point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_point) ⇒ Point

Returns a new instance of Point.



6
7
8
9
# File 'lib/simplify_rb/point.rb', line 6

def initialize(raw_point)
  @original_entity = raw_point
  @x, @y = parse_x_y(raw_point)
end

Instance Attribute Details

#keepObject

Returns the value of attribute keep.



4
5
6
# File 'lib/simplify_rb/point.rb', line 4

def keep
  @keep
end

#original_entityObject (readonly)

Returns the value of attribute original_entity.



3
4
5
# File 'lib/simplify_rb/point.rb', line 3

def original_entity
  @original_entity
end

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/simplify_rb/point.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/simplify_rb/point.rb', line 3

def y
  @y
end

Instance Method Details

#get_sq_dist_to(other_point) ⇒ Object



11
12
13
14
15
16
# File 'lib/simplify_rb/point.rb', line 11

def get_sq_dist_to(other_point)
  dx = x - other_point.x
  dy = y - other_point.y

  dx * dx + dy * dy
end