Module: Coords

Defined in:
lib/coords.rb,
lib/coords/polar.rb,
lib/coords/version.rb,
lib/coords/spherical.rb,
lib/coords/cartesian2d.rb,
lib/coords/cartesian3d.rb,
lib/coords/shapes/line2d.rb,
lib/coords/shapes/line3d.rb

Defined Under Namespace

Modules: Shapes Classes: Cartesian2d, Cartesian3d, Polar, Spherical

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.degrees(radians) ⇒ Object



16
17
18
# File 'lib/coords.rb', line 16

def self.degrees(radians)
  radians / (Math::PI / 180)
end

.radians(degrees) ⇒ Object



12
13
14
# File 'lib/coords.rb', line 12

def self.radians(degrees)
  degrees * (Math::PI / 180)
end

.rotate_matrix(matrix, times = 1, clockwise = true) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/coords.rb', line 20

def self.rotate_matrix(matrix, times = 1, clockwise = true)
  new_matrix = matrix
  times.times.each do |i|
    new_matrix = clockwise ? new_matrix.reverse.transpose : new_matrix.transpose.reverse
  end
  new_matrix
end