class CrystalScad::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/crystalscad/ScrewThreads.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/crystalscad/ScrewThreads.rb, line 56 def orientation_swap_to(coords,rotation) if rotation[:x].to_i == -90 return [coords[0],coords[2],-coords[1]] end if rotation[:x].to_i == 90 return [coords[0],-coords[2],coords[1]] end if rotation[:y].to_i == -90 return [coords[2],coords[1],coords[0]] end if rotation[:y].to_i == 90 return [-coords[2],coords[1],-coords[0]] end return coords end
output()
click to toggle source
# File lib/crystalscad/ScrewThreads.rb, line 52 def output show end
position_on(other_thread,rotation={})
click to toggle source
# File lib/crystalscad/ScrewThreads.rb, line 73 def position_on(other_thread,rotation={}) if other_thread.kind_of? Bolt # we assume that a bolt is always centered and center the object on # the screwthread position return {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) return {x:@x-oc[0],y:@y-oc[1],z:@z-oc[2]} end end
rotation()
click to toggle source
# File lib/crystalscad/ScrewThreads.rb, line 31 def rotation case @face.to_s when "top" return {} when "bottom" return {y:180} when "left" return {y:-90} when "right" return {y:90} when "front" # checkme return {x:90} when "back" return {x:-90} end end
show()
click to toggle source
# File lib/crystalscad/ScrewThreads.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