Collision Detection
-
Hello everyone
The following figure...
a and b intersect
b and c intersect
a and c not intersectI get Leny, Lenz from dynamic attributes(inch)
How not to let the detected twice?(a&b and b&a)
Thank you for your help!
mod = Sketchup.active_model
ent = mod.entities
grp = ent.grep(Sketchup::ComponentInstance)
for i in 0...grp.length - 1
grp.each{ |g| next if g == grp[i] # skip comparing to self
bb = Geom::BoundingBox.new.add(g.bounds.intersect(grp[i].bounds))
if bb.valid?#gg = g.get_attribute("dynamic_attributes","lenx","")
gg1 = g.get_attribute("dynamic_attributes","leny","")
gg2 = g.get_attribute("dynamic_attributes","lenz","")
#puts gg#.to_cm
puts gg1#.to_cm
puts gg2#.to_cm#gg3 = grp[i].get_attribute("dynamic_attributes","lenx","")
gg4 = grp[i].get_attribute("dynamic_attributes","leny","")
gg5 = grp[i].get_attribute("dynamic_attributes","lenz","")
#puts gg3#.to_cm
puts gg4#.to_cm
puts gg5#.to_cmq = gg1.to_i * gg2.to_i - gg4.to_i * gg5.to_i
puts q
#puts "#{g.name} and #{grp[i].name} intersect"
else
puts "#{g.name} and #{grp[i].name} do not intersect"
end
bb.clear
}
end
Advertisement