Class: Shape

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

Instance Method Summary collapse

Instance Method Details

#*(right) ⇒ Object



55
56
57
# File 'lib/rcad.rb', line 55

def *(right)
  Intersection.new(self, right)
end

#+(right) ⇒ Object



47
48
49
# File 'lib/rcad.rb', line 47

def +(right)
  Union.new(self, right)
end

#-(right) ⇒ Object



51
52
53
# File 'lib/rcad.rb', line 51

def -(right)
  Difference.new(self, right)
end

#bboxObject



113
114
115
# File 'lib/rcad.rb', line 113

def bbox
  # TODO
end

#extrude(height, twist = 0) ⇒ Object



105
106
107
# File 'lib/rcad.rb', line 105

def extrude(height, twist=0)
  LinearExtrusion.new(self, height, twist)
end

#max_xObject



129
130
131
# File 'lib/rcad.rb', line 129

def max_x
  bbox[1].x
end

#max_yObject



133
134
135
# File 'lib/rcad.rb', line 133

def max_y
  bbox[1].y
end

#max_zObject



137
138
139
# File 'lib/rcad.rb', line 137

def max_z
  bbox[1].z
end

#min_xObject



117
118
119
# File 'lib/rcad.rb', line 117

def min_x
  bbox[0].x
end

#min_yObject



121
122
123
# File 'lib/rcad.rb', line 121

def min_y
  bbox[0].y
end

#min_zObject



125
126
127
# File 'lib/rcad.rb', line 125

def min_z
  bbox[0].z
end

#move_x(delta) ⇒ Object



69
70
71
# File 'lib/rcad.rb', line 69

def move_x(delta)
  move(delta, 0, 0)
end

#move_y(delta) ⇒ Object



73
74
75
# File 'lib/rcad.rb', line 73

def move_y(delta)
  move(0, delta, 0)
end

#move_z(delta) ⇒ Object



77
78
79
# File 'lib/rcad.rb', line 77

def move_z(delta)
  move(0, 0, delta)
end

#renderObject

if @shape isn’t defined in a Shape’s initialize() method, then render() should be overridden to create and return it on-the-fly.



43
44
45
# File 'lib/rcad.rb', line 43

def render
  @shape
end

#revolve(angle = 360.deg_to_rad) ⇒ Object



109
110
111
# File 'lib/rcad.rb', line 109

def revolve(angle=360.deg_to_rad)
  Revolution.new(self, angle)
end

#rot_x(angle) ⇒ Object



81
82
83
# File 'lib/rcad.rb', line 81

def rot_x(angle)
  rotate(angle, [1, 0, 0])
end

#rot_y(angle) ⇒ Object



85
86
87
# File 'lib/rcad.rb', line 85

def rot_y(angle)
  rotate(angle, [0, 1, 0])
end

#rot_z(angle) ⇒ Object



89
90
91
# File 'lib/rcad.rb', line 89

def rot_z(angle)
  rotate(angle, [0, 0, 1])
end

#scale_x(factor) ⇒ Object



93
94
95
# File 'lib/rcad.rb', line 93

def scale_x(factor)
  scale(factor, 1, 1)
end

#scale_y(factor) ⇒ Object



97
98
99
# File 'lib/rcad.rb', line 97

def scale_y(factor)
  scale(1, factor, 1)
end

#scale_z(factor) ⇒ Object



101
102
103
# File 'lib/rcad.rb', line 101

def scale_z(factor)
  scale(1, 1, factor)
end

#x_sizeObject



141
142
143
# File 'lib/rcad.rb', line 141

def x_size
  max_x - min_x
end

#y_sizeObject



145
146
147
# File 'lib/rcad.rb', line 145

def y_size
  max_y - min_y
end

#z_sizeObject



149
150
151
# File 'lib/rcad.rb', line 149

def z_size
  max_z - min_z
end

#~@Object



59
60
61
62
63
64
65
66
67
# File 'lib/rcad.rb', line 59

def ~@
  if $shape_mode == :hull
    $shape << self
  else
    $shape = ($shape == nil) ? self : $shape.send($shape_mode, self)
  end

  self
end