collision-detection

iOS - Drag and drop collision detection How to detect when your selected item drags over another subview?

北城余情 提交于 2019-12-04 08:19:19
问题 We are adding drag and drop functionality to what is to become a sports field with positions for players. The positions are mapped out using Interface Builder with each being a separate UIImageView. We want to be able to drag player images from bench positions from the side of the screen onto positions on the field. How best can we detect when the selected player which is being moved around collides with an existing gamePosition imageView? We are looking for a way to detect if there is a view

iPhone iOS5 querying OpenGL ES 2.0 pipeline objects if they are hidden in the view or not…“Occlusion”

亡梦爱人 提交于 2019-12-04 07:02:16
EXT_occlusion_query_boolean is new with OS5.0, it looks to me like not a single person on the entire internet has posted about these new extensions nor used this code.... so here they are set up properly...which is not documented anywhere as far as i can tell... you can imagine how they would go in your code from this little sudo code here: import UIKit/UIKit.h import GLKit/GLKit.h import "GLProgram.h" GLuint testBox,hasBeenTested,theParams; //... glGenQueriesEXT(1, &testBox); glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, testBox); //... draw an object ....... glEndQueryEXT(GL_ANY_SAMPLES_PASSED

Box collision detection and bouncing

本秂侑毒 提交于 2019-12-04 06:24:02
问题 I'm making pong, and am finding it really difficult to write an algorithm that bounces the ball off the four walls properly (I will deal with scoring later on, because only part of the West+East sides will be goals). So at the moment I want the ball to bounce around the box. Detecting whether the ball has hit a wall is easy, but I'm having trouble calculating the new angle. This is what I've come up with so far: if(dstY == 0) { // North wall if(angle < 90) { newAngle = angle + 90; } else {

Triangle to triangle collision detection in 3D

烈酒焚心 提交于 2019-12-04 06:20:29
I understand triangle to triangle collision detection betwheen 2 triangles. Can someone explain how could I use this with a 3D object made-up of 1000s of vertexes? How can I create a list of triangles for each Mesh? Do I have to take every permutation of vertexes? That would lead up to O(n^3) which I find very bad. How can I generalise this? I will require to read data from a format. If all else fails, can someone suggest a format that makes the Mesh from triangles? I would also need a catalog of Meshes for the format, at least for starters. Thanks very much. There are lots of optimizations

Java 2D Collision?

怎甘沉沦 提交于 2019-12-04 06:18:13
问题 Hey guys i'm making a 2D java game and i'm trying to figure out how to make a good collision code. I am currently using the following code: public void checkCollision() { Rectangle player_rectangle = new Rectangle(player.getX(),player.getY(),32,32); for(Wall wall : walls) { Rectangle wall_rectangle = new Rectangle(wall.getX(), wall.getY(), 32,32); if (player_rectangle.intersects(wall_rectangle)) { Rectangle intersection = (Rectangle) player_rectangle.createIntersection(wall_rectangle); if

jQuery Dragging With Collision Detection

断了今生、忘了曾经 提交于 2019-12-04 05:48:49
I have the following HTML: <div class="list" id="list"> <div class="item" id="i1">Item 1</div> <div class="item" id="i2">Item 2</div> <div class="item" id="i3">Item 3</div> </div> <div class="timeline" id="timeline"> </div> What I want to be able to do, with jQuery, is: Be able to drag .item s from the #list into the #timeline .item s can be dropped into the timeline as many times as required, eg. there could be 4 of item #i1 in the timeline. .item s in the timeline must not overlap each other .item s can be positioned at any place along the timeline so long as they do not overlap any other

Move rectangles so they don't overlap

南笙酒味 提交于 2019-12-04 04:01:45
This is a half programming, half math question. I've got some boxes, which are represented as four corner points. They are true rectangles, the intersections of two sets of parallel lines, with every line in each set at a right angle to both lines in the other set (just so we're clear.) For any set of n boxes, how can I efficiently calculate where to move them (the least distance) so that they do not overlap each other? I'm working in javascript here. Here's the data: //an array of indefinite length of boxes //boxes represented as arrays of four points //points represented as arrays of two

Separating Axis Test for Axis-Aligned Bounding Box and Triangle produces incorrect results (3D)

瘦欲@ 提交于 2019-12-04 04:01:06
问题 I'm doing triangle to AABB intersection tests, and I'm taking this sample code from Real-Time Collision Detection by Christer Ericson. What the author says in the book before he gives the example is different from the example so I'm not sure how to test the remaining axes.. a01-a22. Test: Nine axes given by the cross products of combination of edges from both. // Test axes a00..a22 ( category 3 ) // Test axis a00 originDistance0 = triangle.point0.z * triangle.point1.y - triangle.point0.y *

Click on given element in canvas

坚强是说给别人听的谎言 提交于 2019-12-04 03:58:35
问题 Is there any trick to determine if user clicks on given element rendered in canvas? For example I'm displaying rhombus from .png file with transparent background and i want to know if user click inside or outside that figure (like mouse-element collision). 回答1: There is no concept of individual elements in a canvas - it is simply just an area that you're drawing pixels onto. SVG on the other hand is made up of elements which you can then bind events to. However there are a few approaches you

2D collision between a moving circle and a fixed line segment

本秂侑毒 提交于 2019-12-04 03:56:11
In the context of a game program, I have a moving circle and a fixed line segment. The segment can have an arbitrary size and orientation. I know the radius of the circle: r I know the coordinates of the circle before the move: (xC1, yC1) I know the coordinates of the circle after the move: (xC2, yC2) I know the coordinates of the extremities of the line segment: (xL1, yL1) - (xL2, yL2) I am having difficulties trying to compute: A boolean : If any part of the circle hits the line segment while moving from (xC1, yC1) to (xC2, yC2) If the boolean is true, the coordinates (x, y) of the center of