collision-detection

Detect if a cube and a cone intersect each other?

夙愿已清 提交于 2019-12-18 11:46:40
问题 Consider two geometrical objects in 3D: a cube aligned with the axes and defined by the position of its center and its extent (edge length) a cone not aligned with the axes and defined by the position of its vertex, the position of the center of its base, and the half-angle at the vertex Here is a small code to define these objects in C++: // Preprocessor #include <iostream> #include <cmath> #include <array> // 3D cube from the position of its center and the side extent class cube { public:

Detecting div collision?

时光总嘲笑我的痴心妄想 提交于 2019-12-18 04:23:08
问题 This is what I am doing right now: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>untitled</title> <meta name="generator" content="TextMate http://macromates.com/"> <style type="text/css" media="screen"> body { font-family:"HelveticaNeue-Light"; margin: 0px; } input { width: 75%; } #wrap { background: #f1f1f1; border: 1px solid #d9d9d9; padding: 0px; }

An efficient way to simulate many particle collisions?

梦想的初衷 提交于 2019-12-17 23:34:59
问题 I would like to write a small program simulating many particle collisions, starting first in 2D (I would extend it to 3D later on), to (in 3D) simulate the convergence towards the Boltzmann distribution and also to see how the distribution evolves in 2D. I have not yet started programming, so please don't ask for code samples, it is a rather general question that should help me get started. There is no problem for me with the physics behind this problem, it is rather the fact that I will have

What technique should be used to prune 2d collision checks?

女生的网名这么多〃 提交于 2019-12-17 22:24:15
问题 From the outset, collision detection feels like it is an O(n^2) problem. You have a bunch of objects and you need to check if each object is colliding with any of the other objects. However, I know that it is wildly ineffecient to check each object against all the other objects. Why do a relatively expensive collision check between two balls if they aren't even close to eachother? Here is example of my simple program I'm working on: If you have 1000 balls then if you went with the naive

How do I implement collision detection between a set of Div elements?

☆樱花仙子☆ 提交于 2019-12-17 20:47:22
问题 I have this example in jsfiddle I have a var as being the collision element: var $div = $('.container'); and then the collision: function test (){ $('.drag') .drag("start",function( ev, dd ){ dd.limit = $div.offset(); dd.limit.bottom = dd.limit.top + $div.outerHeight() - $( this ).outerHeight(); dd.limit.right = dd.limit.left + $div.outerWidth() - $( this ).outerWidth(); }) .drag(function( ev, dd ){ $( this ).css({ top: Math.min( dd.limit.bottom, Math.max( dd.limit.top, dd.offsetY ) ), left:

Collision detection between a line and a circle in JavaScript

和自甴很熟 提交于 2019-12-17 20:37:51
问题 I'm looking for a definitive answer, maybe a function cos I'm slow, that will determine if a line segment and circle have collided, in javascript (working with canvas) A function like the one below that simply returns true if collided or false if not would be awesome. I might even donate a baby to you. function isCollided(lineP1x, lineP1y, lineP2x, lineP2y, circlex, circley, radius) { ... } I've found plenty of formulas, like this one, but they are over my head. 回答1: Here you will need some

Unity Physics2D.Raycast hits itself

落花浮王杯 提交于 2019-12-17 17:16:17
问题 I'm trying to use Physics2D.Raycast in order to check if the player is on the ground (I know that there are other approaches to check if the player is on the ground but I think that the raycast is the most reliable). The problem is that in my scenario it returns the player itself as hit and I really don't understand why and what should I do. My code (in PlayerController ) is the following: public bool IsGrounded () { Bounds bounds = this.playerCollider.bounds; Vector3 rayOrigin = bounds

Circle and Polygon Collision with Libgdx

你离开我真会死。 提交于 2019-12-17 15:58:26
问题 Is there a way in Libgdx to verify a collision between a Polygon and a Circle? I saw the Intersector class but only found collision test for Circle and Rectangle. What about any other Polygon? If I need to do it manually, what's the best way to do that using Libgdx? 回答1: So, I managed to create a collision test method between a Circle and a Polygon. At least, it works for me. Here's the code: public boolean overlaps(Polygon polygon, Circle circle) { float []vertices=polygon

Sprite-Kit registering multiple collisions for single contact

﹥>﹥吖頭↗ 提交于 2019-12-17 13:27:46
问题 OK - I’m sure this is a duplicate and that Whirlwind or KnightOfDragons has posted a solution, but I can’t find it. I’m writing a clone of Space Invader in Swift using Sprite-Kit. The problem I have is that when a invader bomb hits my ship, the code sometimes registers 2 or 3 collisions, immediately ending the game. Here’s the section of ‘didBeginContact’ that handles the bomb/ship collision: case category.bomb.rawValue | category.ship.rawValue: print("Bomb hit ship!") let bomb = contact

How can I perform Collision Detection on rotated rectangles? [closed]

半世苍凉 提交于 2019-12-17 10:57:42
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Okay, I'm trying to write a program that could tell me if any points in a 30x100 rectangle rotated to 140 degrees are inside another 30x100 rectangle rotated to 200 degrees. Honestly, I don't even know where to start. I thought about re-rotating them before doing normal