Class: Geom::Vertex

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/geom/vertex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0.0, y = 0.0, z = 0.0, normal = nil) ⇒ Vertex

Returns a new instance of Vertex.



10
11
12
13
# File 'lib/geom/vertex.rb', line 10

def initialize(x=0.0,y=0.0,z=0.0,normal=nil)
  @position = Number3D.new(x,y,z)
  @normal = normal
end

Instance Attribute Details

#normalObject

Returns the value of attribute normal.



5
6
7
# File 'lib/geom/vertex.rb', line 5

def normal
  @normal
end

#positionObject

Returns the value of attribute position.



5
6
7
# File 'lib/geom/vertex.rb', line 5

def position
  @position
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/geom/vertex.rb', line 15

def == (other)
  @position == other.position
end

#cloneObject



25
26
27
# File 'lib/geom/vertex.rb', line 25

def clone
  Vertex.new(x,y,z)
end

#equal?(other, snap) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/geom/vertex.rb', line 19

def equal?(other,snap)
  @position.x-snap < other.x && @position.x+snap > other.x &&
  @position.y-snap < other.y && @position.y+snap > other.y &&
  @position.z-snap < other.z && @position.z+snap > other.z
end

#to_sObject



29
30
31
# File 'lib/geom/vertex.rb', line 29

def to_s
  "#<Geom::Vertex:#{@position.to_s}>"
end