Sha256: ee348d961a513ad8b843da91411c617bac8db134c4a7512212ba2944553b7225

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

#! /usr/bin/env ruby # coding: utf-8

class CrystalCell::Povray::Tetrahedron < Mageo::Tetrahedron
  
  attr_accessor :color, :transmit
  
  # color should be Array like [r, g, b]. Float from 0.0 to 1.0.
  def initialize(v0, v1, v2, v3, color, transmit = nil)
    super(v0, v1, v2, v3)
    @color =  color
    @transmit =  transmit
  end

  # povray 形式の文字列を返す。
  # color は Float による配列。通常、0〜1の範囲。
  def to_pov
    triangles.map { |triangle| triangle.to_pov }.join("\n")
  end

  def dump(io)
    io.puts self.to_pov
  end

  def triangles
    results = VERTEX_INDICES_OF_TRIANGLES.map do |indices|
    CrystalCell::Povray::Triangle.new( *(indices.map{|i| @vertices[i] }), @color, @transmit )
    end
    return results
  end

  private

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
crystalcell-0.1.1 lib/crystalcell/povray/tetrahedron.rb
crystalcell-0.1.0 lib/crystalcell/povray/tetrahedron.rb