collision-detection

Sphere - sphere collision detection -> reaction

落爺英雄遲暮 提交于 2019-11-30 04:42:52
问题 I need to make an algorithm that detects when two spheres collide, and, the direction that wich one will take an instant after the collision. Let say, Imagine like when you open your table in a pool match, all the balls are colliding one to another "randomly". So, before starting to write the code myself, I was thinking if there is already a implementation of this out there. Thx in advance! Cyas.- 回答1: The collision part is easy. Check if the distance between the spheres centers is less than

Method to detect intersection between a rectangle and a polygon?

寵の児 提交于 2019-11-30 03:51:27
问题 What is the best method to detect whether the red rectangle overlaps the black polygon? Please refer to this image: 回答1: There are four cases. Rect is outside of Poly Rect intersects Poly Rect is inside of Poly Poly is inside of Rect First: check an arbitrary point in your Rect against the Poly (see Point in Polygon). If it's inside you are done, because it's either case 3 or 2. If it's outside case 3 is ruled out. Second: check an arbitrary point of your Poly against the Rect to validate

QuadTree for 2D collision detection

无人久伴 提交于 2019-11-29 23:12:21
I'm currently working on a 2D shoot them up type of game, and I'm using a quad tree for my collision detections. I wrote a working quad tree that correctly pushes my actors into the nodes/leaves they belong to in the tree. However, I've got a few problems. Firstly, how do I actually use my quadtree to select against which other objects an object should test collisions ? I'm unsure about how this is done. Which brings up a second question. Say I have an object in node that is not a neighbour of another node, but that the object is large enough that it spans a few node, how can I check for an

Find whether two triangles intersect or not

╄→尐↘猪︶ㄣ 提交于 2019-11-29 21:30:38
Given 2 set of points ((x1,y1,z1),(x2,y2,z2),(x3,y3,z3)) and ((p1,q1,r1),(p2,q2,r2),(p3,q3,r3)) each forming a triangle in 3D space. How will you find out whether these triangles intersect or not? One obvious solution to this problem is to find the equation of the plane formed by each triangle. If the planes are parallel, then they don't intersect. Else, find out the equation of line formed by the intersection of these planes using the normal vectors of these planes. Now, if this line lies in both of the triangular regions, then these two triangles intersect, otherwise not. trianglesIntersect

Dragging collisions

情到浓时终转凉″ 提交于 2019-11-29 17:43:19
I am pretty new to both CANVAS and Kineticjs but I feel what I am attemping should be much easier then I am making it out to be. Basically this is what I have so far: The code I am attempting to use is from kineticjs Stop drag to a shape when overlaps with another solution but was unable to get it to work. Please check the live jsfiddle code var isRectCollide = function(target, box) { if (target.x - target.width >= box.x + box.width && target.y - target.height >= box.y + box.height && target.x + target.width <= box.x + box.width && target.x + target.height <= box.y - box.height ) return false;

RayCasting in Libgdx 3d

社会主义新天地 提交于 2019-11-29 15:20:13
Alright so I've been trying for quite some time too Raycast in libgdx for 3d collision detection based on where im looking.. But I've drawn a blank and doesn't seem to be any documentation anywhere. Would someone be kind enough to send me in the right direction? It is actually really easy with libgdx to achieve what you are trying to do. The following is what I'm using to do a ray test and find the closest collision object that my ray would hit. Let's assume it is located in a class called BulletUtil . private static final Vector3 rayFrom = new Vector3(); private static final Vector3 rayTo =

Sprite Kit's 'didBeginContact' function is not very accurate. What should I do?

*爱你&永不变心* 提交于 2019-11-29 15:18:11
问题 Okay, here's the deal: I'm developing a 2D car game (similar to Hill Climb Racing) in Sprite Kit for iOS. I'm currently working on dust particles, which show up whenever a tire touches a surface that has this effect assigned to it. For this, I obviously need the functions 'didBeginContact' and 'didEndContact' so that I can turn the effect on/off depending on whether the tires are touching the ground or not. Here's what I want to do: /* ---- very dirty pseudocode ---- */ didBeginContact { if

Javascript canvas collision detection

烈酒焚心 提交于 2019-11-29 14:55:06
问题 I'm building a game in Javascript using canvas which requires collision detection, in this case if the player sprite hits a box, the player must not be allowed through the box. I have a global array called blockList that holds all the boxes being drawn to the canvas. It looks like this: var blockList = [[50, 400, 100, 100]]; And they're being drawn to the canvas like this: c.fillRect(blockList[0][0], blockList[0][1], blockList[0][2], blockList[0][3]); I also have a player object, which has an

Qt - circles for collision detection

孤者浪人 提交于 2019-11-29 14:52:01
I've been working on a physics simulation with circles in Qt. Thus far the easiest way to define circles I found is to make a QRect object and then draw the ellipse with that rectangle as a "blueprint". Now I've just got the problem that it paints a circle but the hit box for the hit detection is still a square, which looks rather awkward. I've not been able to find a solution for it thus far and hope to find some help here. QRectF Ball::boundingRect() const { return QRect(0,0,20,20); } void Ball::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QRectF rec =

XNA 3d physics engine [closed]

时光毁灭记忆、已成空白 提交于 2019-11-29 13:48:55
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am looking for a 3D physics engine for XNA. I heard of some options, but what I need is: free for commercial purposes (preferable