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



23
24
25
# File 'lib/geom/vertex.rb', line 23

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

#cloneObject



33
34
35
# File 'lib/geom/vertex.rb', line 33

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


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

def eql?(other)
  self == other
end

#equal?(other, snap) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#hashObject



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

def hash
  @position.hash
end

#to_sObject



37
38
39
# File 'lib/geom/vertex.rb', line 37

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