Sha256: 0047350ef193d711b55eb43653df19c075adf350ba6f6e8e9bedc117aab9ee00

Contents?: true

Size: 466 Bytes

Versions: 1

Compression:

Stored size: 466 Bytes

Contents

class GeometricDistance < Struct.new(:point1, :point2)

	def self.new_by_arrays(point1_coordinates, point2_coordinates)
    self.new(GeometricPoint.new_by_array(point1_coordinates),
             GeometricPoint.new_by_array(point2_coordinates))
  end

  def distance
    Math.hypot(point1.x - point2.x, point1.y - point2.y)
  end

  def midpoint
    [((point2.x + point1.x) / 2), ((point2.y + point1.y) / 2)]
  end

  def midpoint_distance
    distance / 2
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flash_math-0.0.1 lib/flash_math/modules/geometry/geometric_distance.rb