Class: Wavefront::Vec3

Inherits:
Object
  • Object
show all
Defined in:
lib/wavefront/vec3.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Vec3

Returns a new instance of Vec3.



5
6
7
8
9
# File 'lib/wavefront/vec3.rb', line 5

def initialize *args
  @x = args[0] if args.size > 0
  @y = args[1] if args.size > 1
  @z = args[2] if args.size > 2
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



3
4
5
# File 'lib/wavefront/vec3.rb', line 3

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



3
4
5
# File 'lib/wavefront/vec3.rb', line 3

def y
  @y
end

#zObject (readonly)

Returns the value of attribute z.



3
4
5
# File 'lib/wavefront/vec3.rb', line 3

def z
  @z
end

Instance Method Details

#to_aObject



15
16
17
# File 'lib/wavefront/vec3.rb', line 15

def to_a
  [x, y, z]
end

#to_sObject



11
12
13
# File 'lib/wavefront/vec3.rb', line 11

def to_s
  to_a.compact.join ' '
end