Sha256: 152b4f4e74b8d5aaa3bacbdd4faccc99191f7b990bb0335fb24f93fbe4da87de
Contents?: true
Size: 1010 Bytes
Versions: 6
Compression:
Stored size: 1010 Bytes
Contents
# -*- coding: utf-8 -*- require 'rays/ext' module Rays class Point include Comparable def move_to (*args) dup.move_to! *args end def move_by (*args) dup.move_by! *args end def to_a (dimension = 2) case dimension when 1 then [x] when 2 then [x, y] when 3 then [x, y, z] else raise ArgumentError end end def + (*args) op_add Point.from(*args) end def - (*args) op_sub Point.from(*args) end def * (*args) op_mult Point.from(*args) end def / (*args) op_div Point.from(*args) end def <=> (o) ret = x <=> o.x; return ret if ret != 0 ret = y <=> o.y; return ret if ret != 0 z <=> o.z end def self.from (*args) case arg0 = args[0] when Point then arg0 when Array then Point.new *arg0 when Numeric then Point.new arg0, arg0, arg0 else raise ArgumentError end end end# Point end# Rays
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
rays-0.1.12 | lib/rays/point.rb |
rays-0.1.11 | lib/rays/point.rb |
rays-0.1.10 | lib/rays/point.rb |
rays-0.1.9 | lib/rays/point.rb |
rays-0.1.8 | lib/rays/point.rb |
rays-0.1.7 | lib/rays/point.rb |