class SolidRuby::ScrewThreads::ScrewThread
Attributes
depth[RW]
I would name this Thread but that's already taken by something else
face[RW]
I would name this Thread but that's already taken by something else
size[RW]
I would name this Thread but that's already taken by something else
x[RW]
I would name this Thread but that's already taken by something else
y[RW]
I would name this Thread but that's already taken by something else
z[RW]
I would name this Thread but that's already taken by something else
Public Class Methods
new(args = {})
click to toggle source
# File lib/solidruby/screw_thread.rb, line 22 def initialize(args = {}) @x = args[:x] || 0 @y = args[:y] || 0 @z = args[:z] || 0 @depth = args[:depth] @size = args[:size] @face = args[:face] || :top end
Public Instance Methods
orientation_swap_to(coords, rotation)
click to toggle source
# File lib/solidruby/screw_thread.rb, line 56 def orientation_swap_to(coords, rotation) return [coords[0], coords[2], -coords[1]] if rotation[:x].to_i == -90 return [coords[0], -coords[2], coords[1]] if rotation[:x].to_i == 90 return [coords[2], coords[1], coords[0]] if rotation[:y].to_i == -90 return [-coords[2], coords[1], -coords[0]] if rotation[:y].to_i == 90 coords end
output()
click to toggle source
# File lib/solidruby/screw_thread.rb, line 52 def output show end
position_on(other_thread, rotation = {})
click to toggle source
# File lib/solidruby/screw_thread.rb, line 65 def position_on(other_thread, rotation = {}) if other_thread.is_a? Bolt # we assume that a bolt is always centered and center the object on # the screwthread position { x: -@x, y: -@y, z: -@z } else # on a screwthread find out its position and orientation oc = other_thread.x, other_thread.y, other_thread.z oc = orientation_swap_to(oc, rotation) { x: @x - oc[0], y: @y - oc[1], z: @z - oc[2] } end end
rotation()
click to toggle source
# File lib/solidruby/screw_thread.rb, line 31 def rotation case @face.to_s when 'top' {} when 'bottom' { y: 180 } when 'left' { y: -90 } when 'right' { y: 90 } when 'front' # checkme { x: 90 } when 'back' { x: -90 } end end
show()
click to toggle source
# File lib/solidruby/screw_thread.rb, line 48 def show cylinder(d: @size, h: @depth).rotate(rotation).translate(x: @x, y: @y, z: @z).color(r: 130, g: 130, b: 130) end