Sha256: 5ca9cc09dec73effab3c06ff4798fa5c57f8824c1617cb74f57a3db97376104d

Contents?: true

Size: 285 Bytes

Versions: 2

Compression:

Stored size: 285 Bytes

Contents

require 'geom3d/point'

module Geom3d
  class Line
    attr_reader :p1, :p2

    def initialize p1, p2
      @p1 = Point.new(p1)
      @p2 = Point.new(p2)
    end

    def pos t
      @p1 + t * (@p2 - @p1)
    end

    def to_s
      "Line(#{@p1.to_s}, #{@p2.to_s})"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geom3d-0.1.1 lib/geom3d/line.rb
geom3d-0.1.0 lib/geom3d/line.rb