Class: KvgCharacterRecognition::KvgParser::Point
- Inherits:
-
Object
- Object
- KvgCharacterRecognition::KvgParser::Point
- Defined in:
- lib/kvg_character_recognition/kvg_parser.rb
Overview
A Point
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #*(number) ⇒ Object
-
#+(p2) ⇒ Object
Basic point arithmetics.
- #-(p2) ⇒ Object
- #dist(p2) ⇒ Object
-
#initialize(x, y, color = :black) ⇒ Point
constructor
A new instance of Point.
-
#to_a ⇒ Object
to array.
Constructor Details
#initialize(x, y, color = :black) ⇒ Point
Returns a new instance of Point.
10 11 12 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 10 def initialize(x,y, color = :black) @x,@y, @color = x, y, color end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
8 9 10 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 8 def color @color end |
#x ⇒ Object
Returns the value of attribute x.
8 9 10 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 8 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
8 9 10 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 8 def y @y end |
Instance Method Details
#*(number) ⇒ Object
27 28 29 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 27 def *(number) return Point.new(@x * number, @y * number) end |
#+(p2) ⇒ Object
Basic point arithmetics
15 16 17 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 15 def +(p2) return Point.new(@x + p2.x, @y + p2.y) end |
#-(p2) ⇒ Object
19 20 21 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 19 def -(p2) return Point.new(@x - p2.x, @y - p2.y) end |
#dist(p2) ⇒ Object
23 24 25 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 23 def dist(p2) return Math.sqrt((p2.x - @x)**2 + (p2.y - @y)**2) end |
#to_a ⇒ Object
to array
32 33 34 |
# File 'lib/kvg_character_recognition/kvg_parser.rb', line 32 def to_a [@x.round(2), @y.round(2)] end |