Class: SimplifyRb::Point
- Inherits:
-
Object
- Object
- SimplifyRb::Point
- Defined in:
- lib/simplify_rb/point.rb
Instance Attribute Summary collapse
-
#keep ⇒ Object
Returns the value of attribute keep.
-
#original_entity ⇒ Object
readonly
Returns the value of attribute original_entity.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #get_sq_dist_to(other_point) ⇒ Object
-
#initialize(raw_point) ⇒ Point
constructor
A new instance of Point.
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
#keep ⇒ Object
Returns the value of attribute keep.
4 5 6 |
# File 'lib/simplify_rb/point.rb', line 4 def keep @keep end |
#original_entity ⇒ Object (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 |
#x ⇒ Object (readonly)
Returns the value of attribute x.
3 4 5 |
# File 'lib/simplify_rb/point.rb', line 3 def x @x end |
#y ⇒ Object (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 |