Module: BulldogPhysics

Defined in:
lib/bulldog_physics.rb,
lib/matrix3.rb,
lib/matrix4.rb,
lib/vector3.rb,
lib/quaternion.rb,
lib/RigidBodies/joint.rb,
lib/RigidBodies/world.rb,
lib/Particles/particle.rb,
lib/RigidBodies/spring.rb,
lib/RigidBodies/Gravity.rb,
lib/RigidBodies/contact.rb,
lib/Particles/projectile.rb,
lib/RigidBodies/buoyancy.rb,
lib/Particles/particle_rod.rb,
lib/RigidBodies/rigid_body.rb,
lib/Particles/particle_drag.rb,
lib/Particles/particle_link.rb,
lib/Particles/particle_cable.rb,
lib/Particles/particle_world.rb,
lib/Particles/particle_spring.rb,
lib/Particles/particle_contact.rb,
lib/Particles/particle_gravity.rb,
lib/RigidBodies/force_registry.rb,
lib/RigidBodies/force_generator.rb,
lib/RigidBodies/collision_shapes.rb,
lib/RigidBodies/contact_resolver.rb,
lib/RigidBodies/rigid_collisions.rb,
lib/RigidBodies/contact_generator.rb,
lib/RigidBodies/force_registration.rb,
lib/Particles/particle_force_registry.rb,
lib/Particles/particle_anchored_spring.rb,
lib/Particles/particle_force_generator.rb,
lib/Particles/particle_ground_contacts.rb,
lib/Particles/particle_contact_resolver.rb,
lib/Particles/particle_contact_generator.rb,
lib/Particles/particle_particle_contacts.rb,
lib/Particles/particle_force_registration.rb

Overview

require ‘vector3.rb’ require ‘matrix3.rb’ require ‘matrix4.rb’ require ‘quaternion.rb’

Defined Under Namespace

Modules: BSPChildType, Particles Classes: BSPElement, BSPNode, BSPObjectSet, BVHNode, BodyRegistration, BoundingBox, BoundingSphere, Buoyancy, CollisionBox, CollisionData, CollisionDetector, CollisionPlane, CollisionPrimitive, CollisionSphere, Contact, ContactGenRegistration, ContactGenerator, ContactResolver, ForceGenerator, ForceRegistration, ForceRegistry, Gravity, Grid, IntersectionTests, Joint, Matrix3, Matrix4, OctTreeNode, OctTreeSector, Plane, PotentialContact, QuadTreeNode, QuadTreeSector, Quaternion, RigidBody, Spring, Vector3, World

Instance Method Summary collapse

Instance Method Details

#localToWorld(local, transform) ⇒ Object



30
31
32
# File 'lib/bulldog_physics.rb', line 30

def localToWorld(local, transform)
	return tarnsform.transform(local)
end

#overlap_on_axis(one, two, axis, to_centre) ⇒ Object



96
97
98
99
100
101
102
103
# File 'lib/RigidBodies/collision_shapes.rb', line 96

def overlap_on_axis(one, two, axis, to_centre)
	one_project = transform_to_axis(one, axis)
	two_project = transform_to_axis(two, axis)

	distance = (to_centre * axis).abs

	distance < one_project + two_project	
end

#transform_to_axis(box, axis) ⇒ Object



90
91
92
93
94
# File 'lib/RigidBodies/collision_shapes.rb', line 90

def transform_to_axis(box, axis)
	return box.half_size.x * (axis * box.get_axis(0)).abs + \
	box.half_size.y * (axis * box.get_axis(1)).abs + \
	box.half_size.z * (axis * box.get_axis(2)).abs
end

#worldToLocal(world, transform) ⇒ Object



34
35
36
37
38
# File 'lib/bulldog_physics.rb', line 34

def worldToLocal(world, transform)
	inverseTransform = Matrix4.new
	inverseTransform.setInverse(transform)
	return inverseTransform.transform(world)
end