Class: BulldogPhysics::IntersectionTests
- Inherits:
-
Object
- Object
- BulldogPhysics::IntersectionTests
- Defined in:
- lib/RigidBodies/collision_shapes.rb
Class Method Summary collapse
- .box_and_box(one, two) ⇒ Object
- .box_and_half_space(box, plane) ⇒ Object
- .sphere_and_half_space(sphere, plane) ⇒ Object
- .sphere_and_sphere(one, two) ⇒ Object
Class Method Details
.box_and_box(one, two) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/RigidBodies/collision_shapes.rb', line 121 def self.box_and_box(one, two) to_center = two.get_axis(3) - one.get_axis(3) return overlap_on_axis(one,two,one.getAxis(0), to_center) && \ overlap_on_axis(one,two,one.getAxis(1), to_center) && \ overlap_on_axis(one,two,one.getAxis(2), to_center) && \ overlap_on_axis(one,two,two.getAxis(0), to_center) && \ overlap_on_axis(one,two,two.getAxis(1), to_center) && \ overlap_on_axis(one,two,two.getAxis(2), to_center) && \ overlap_on_axis(one,two,one.getAxis(0) % two.getAxis(0), to_center) && \ overlap_on_axis(one,two,one.getAxis(0) % two.getAxis(1), to_center) && \ overlap_on_axis(one,two,one.getAxis(0) % two.getAxis(2), to_center) && \ overlap_on_axis(one,two,one.getAxis(1) % two.getAxis(0), to_center) && \ overlap_on_axis(one,two,one.getAxis(1) % two.getAxis(1), to_center) && \ overlap_on_axis(one,two,one.getAxis(1) % two.getAxis(2), to_center) && \ overlap_on_axis(one,two,one.getAxis(2) % two.getAxis(0), to_center) && \ overlap_on_axis(one,two,one.getAxis(2) % two.getAxis(1), to_center) && \ overlap_on_axis(one,two,one.getAxis(2) % two.getAxis(2), to_center) end |
.box_and_half_space(box, plane) ⇒ Object
142 143 144 145 146 |
# File 'lib/RigidBodies/collision_shapes.rb', line 142 def self.box_and_half_space(box, plane) projection_radius = transform_to_axis( box, plane.direction) box_distance = plane.direction * box.get_axis(3) - projection_radius box_distance < plane.offset end |
.sphere_and_half_space(sphere, plane) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/RigidBodies/collision_shapes.rb', line 107 def self.sphere_and_half_space(sphere, plane) ball_distance = plane.direction * sphere.get_axis(3) - sphere.radius ball_distance <= plane.offset end |
.sphere_and_sphere(one, two) ⇒ Object
114 115 116 117 118 119 |
# File 'lib/RigidBodies/collision_shapes.rb', line 114 def self.sphere_and_sphere(one, two) mid_line = one.get_axis(3) - two.get_axis(3) return mid_line.sqaureMagnitude < (one.radius + two.radius) * (one.radius + two.radius) end |