collision-detection

Basic 2d collision detection

二次信任 提交于 2019-11-26 14:27:32
问题 Where can I go to read more about basic 2d collision detection for games or just applications that have some interactivity? Edit: How about javascript for Canvas games? 回答1: The most important theorem to know is the Separating Axis Theorem (SAT). Basicly, it allows you to detect collision between two convex polygons. A good reading material is here. If your game only concerns with convex shapes, then sat.js is a decent choice. However, if you need to work with concave shapes, you need to

What is AABB - Collision detection?

这一生的挚爱 提交于 2019-11-26 13:01:33
问题 Hi I\'m making a voxel game in Java and while researching all the different things I\'d need to learn, I noticed that a lot of games use AABB for collision detection. And then I remembered seeing AABB in Minecraft also. But when I google what AABB is, it only comes up with other peoples code, or some organization out the history book. Stackoverflow, what is AABB ? 回答1: AABB stands for "Axis-Aligned Bounding Box." It is a fairly computationally- and memory-efficient way of representing a

circle-circle collision

扶醉桌前 提交于 2019-11-26 12:13:37
I am going to develop a 2-d ball game where two balls (circles) collide. Now I have the problem with determining the colliding point (in fact, determining whether they are colliding in x-axis/y-axis). I have an idea that when the difference between the y coordinate of 2 balls is greater than the x coordinate difference then they collide in their y axis, otherwise, they collide in their x axis. Is my idea correct? I implemented this thing in my games. Normally it works well, but sometimes, it fails. Can anyone tell me whether my idea is right? If not, then why, and is any better way? By

How do HashTables deal with collisions?

偶尔善良 提交于 2019-11-26 11:31:52
I've heard in my degree classes that a HashTable will place a new entry into the 'next available' bucket if the new Key entry collides with another. How would the HashTable still return the correct Value if this collision occurs when calling for one back with the collision key? I'm assuming that the Keys are String type and the hashCode() returns the default generated by say Java. If I implement my own hashing function and use it as part of a look-up table (i.e. a HashMap or Dictionary ), what strategies exist for dealing with collisions? I've even seen notes relating to prime numbers!

Bounding ellipse

元气小坏坏 提交于 2019-11-26 11:02:31
问题 I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn\'t have to be axis aligned. This is working in java (euch) using the AWT shapes, so I can use all the tools shape provides for checking containment/intersection of objects. 回答1: You're looking for the Minimum Volume Enclosing Ellipsoid, or in your 2D case, the minimum area. This optimization problem is convex and can be solved

Java rectangle collision detection confusion

混江龙づ霸主 提交于 2019-11-26 09:55:22
问题 I have made a simple 2D state change game using Bucky\'s slick Java tutorials, I modified this game and now want to set collisions on the map so that my player can not go through the house on the map. I think I kind of have a idea of how collisions work: you make 2 rectangles using the following code: public Rectangle getBounds() { return new Rectangle(x, y, width, height); } 1 for the player and 1 for the obstacle, how would I put this into my code and how would I tell java that the

Line intersection with AABB Rectangle?

假如想象 提交于 2019-11-26 07:29:36
问题 Preferably without using any kind of loop, as this\'ll be used in a game. I wish to intersect a line with a rectangle, of arbitrary size. But I also wish for the intersection point[s] to be returned. It\'s possible, I\'ve done a little googling, but still have not worked it out. The line is defined using (x1,y1,x2,y2). The rectangle has these two points too. 回答1: I would recommend simply doing a line-segment-line-segment intersection check on each line segment (edge) that makes up the

Javascript: Collision detection

女生的网名这么多〃 提交于 2019-11-26 03:21:31
问题 could someone please help me to understand how collision detection works in JS? I can\'t use jQuery or gameQuery - already using prototype - so, I\'m looking for something very simple. Not asking for complete solution, just point me to the right direction. Let\'s say there\'s: <div id=\"ball\"></div> and <div id=\"someobject0\"></div> Now the ball is moving (any direction). \"Someobject\"(0-X) is already pre-defined and there\'s 20-60 of them randomly positioned like this: #someobject

How do HashTables deal with collisions?

本秂侑毒 提交于 2019-11-26 02:27:41
问题 I\'ve heard in my degree classes that a HashTable will place a new entry into the \'next available\' bucket if the new Key entry collides with another. How would the HashTable still return the correct Value if this collision occurs when calling for one back with the collision key? I\'m assuming that the Keys are String type and the hashCode() returns the default generated by say Java. If I implement my own hashing function and use it as part of a look-up table (i.e. a HashMap or Dictionary ),

Checking Collision of Shapes with JavaFX

筅森魡賤 提交于 2019-11-26 01:59:44
问题 I am trying to do some collision detection. For this test I am using simple rectangular Shape , and checking their Bound , to figure if they are colliding. Although the detection does not work as expected. I have tried using different ways to move the object(relocate, setLayoutX,Y) and also different bound checks (boundsInLocal,boundsInParrent etc) but I still cannot get this to work. As you can see the detection works only for one object, even when you have three objects only one detects