Sha256: bdb628051fdf44e9ff97b127dd93f91b6ca20986e182eec1dc2160fc08f9c173

Contents?: true

Size: 977 Bytes

Versions: 4

Compression:

Stored size: 977 Bytes

Contents

require 'mittsu/core'
require 'mittsu/math'
require 'mittsu/extras/geometries/polyhedron_geometry'

module Mittsu
  class IcosahedronGeometry < PolyhedronGeometry
    def initialize(radius = 1.0, detail = 0)
      t = (1.0 + ::Math.sqrt(5)) / 2.0

      vertices = [
        - 1,  t,  0,    1,  t,  0,   - 1, - t,  0,    1, - t,  0,
        0, - 1,  t,    0,  1,  t,    0, - 1, - t,    0,  1, - t,
        t,  0, - 1,    t,  0,  1,   - t,  0, - 1,   - t,  0,  1
      ]

      indices = [
        0, 11,  5,    0,  5,  1,    0,  1,  7,    0,  7, 10,    0, 10, 11,
        1,  5,  9,    5, 11,  4,   11, 10,  2,   10,  7,  6,    7,  1,  8,
        3,  9,  4,    3,  4,  2,    3,  2,  6,    3,  6,  8,    3,  8,  9,
        4,  9,  5,    2,  4, 11,    6,  2, 10,    8,  6,  7,    9,  8,  1
      ]

      super(vertices, indices, radius, detail)

      @type = 'IcosahedronGeometry'

      @parameters = {
        radius: radius,
        detail: detail
      }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mittsu-0.5.0 lib/mittsu/extras/geometries/icosahedron_geometry.rb
mittsu-0.4.1 lib/mittsu/extras/geometries/icosahedron_geometry.rb
mittsu-0.4.0 lib/mittsu/extras/geometries/icosahedron_geometry.rb
mittsu-0.3.3 lib/mittsu/extras/geometries/icosahedron_geometry.rb