class KMeansPP::BasePoint
Common methods for Point
and Centroid
.
Attributes
x[RW]
X coordinate of the point.
@return [Float]
y[RW]
Y coordinate of the point.
@return [Float]
Public Instance Methods
squared_distance_to(point)
click to toggle source
Measure a 2D squared distance between two points.
@param point [BasePoint]
@return [Float]
# File lib/k_means_pp/point.rb, line 19 def squared_distance_to(point) distance_x = x - point.x distance_y = y - point.y squared_distance = distance_x**2 + distance_y**2 squared_distance end
to_s()
click to toggle source
A string representation of the point.
# File lib/k_means_pp/point.rb, line 27 def to_s "(#{x}, #{y})" end