标签: collision-detection

GJK中的碰撞点

有没有办法修改Gilbert-Johnson-Keerthi算法,以便找到两个物体之间碰撞的点而不是真/假结果?根据我的理解,可以使用接收到的距离值来找到这些点.我在网上搜索但没有找到任何提示.

algorithm collision-detection

6
推荐指数
1
解决办法
2285
查看次数

检测移动物体和不动物体之间的碰撞

首先,我的问题并不是特定于C#或XNA,但我的代码示例将使用这些.

我目前正在尝试制作一个Pong克隆,我遇到了碰撞检测的问题.

每个对象基本上都有一个特定的速度(Vector2),Position(Vector2,也是)和Speed(只是一个浮点数).在对象的每次Update()调用中,位置都会以这种方式更改:

Velocity.Normalize();
Position += Velocity * Speed;
Run Code Online (Sandbox Code Playgroud)

首先,我只检查了两个对象之间是否存在碰撞,并且从对象的矩形进行简单的Intersects()调用.我很快意识到,我不仅可以检查对象当前是否与另一个物体发生碰撞,而是检查物体是否与物体碰撞.只检查两个物体当前是否发生碰撞,当速度过高时,球会通过桨叶.

我尝试了不同的方法来解决问题,但它们似乎都没有用.我只需要一种方法来检查两个物体是否在它们的路上相撞,如果它们是,它是从水平,垂直还是两者(相应地改变球的速度).

我不一定非常想要解决方案,也许只是如何实现它的基本思想,我将自己编写代码.

谢谢你的时间.

c# xna collision-detection

6
推荐指数
1
解决办法
1万
查看次数

三角形到三角形碰撞检测

我理解三角形到三角形的碰撞检测两个三角形.有人可以解释我如何使用由1000个顶点组成的3D对象?如何为每个网格创建三角形列表?我是否必须采用每个顶点的排列?这将导致O(n ^ 3),我发现非常糟糕.

我该如何概括呢?

我将要求从格式中读取数据.如果所有其他方法都失败了,有人会建议一种格式,使三角形的网格?我还需要一个Meshes目录作为格式,至少对于初学者来说.

非常感谢.

collision-detection

6
推荐指数
1
解决办法
3234
查看次数

如何在一组Div元素之间实现碰撞检测?

我在jsfiddle中有这个例子

我有一个var作为碰撞元素:

var $div = $('.container');
Run Code Online (Sandbox Code Playgroud)

然后碰撞:

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: Math.min( dd.limit.right, Math.max( dd.limit.left, dd.offsetX ) )
            });   
        });
}
Run Code Online (Sandbox Code Playgroud)

对于:

<div class="container"></div>
<div class="drag xxx" style="left:40px;"></div>
<div class="drag xxx" style="left:120px;"></div>
<div class="drag xxx" style="left:200px;"></div> …
Run Code Online (Sandbox Code Playgroud)

jquery collision-detection

6
推荐指数
1
解决办法
9980
查看次数

实现"三角内检查点"算法时出错

我下面的算法1 这篇文章来检查点的三角形内.这是我的代码:

//========================================================================================================================//
// Methods
//========================================================================================================================//

private float getPerpDotProduct(final PointF p1, final PointF p2) {
    return p1.x * p2.y - p1.y * p2.x;
}

private boolean isInside(final PointF pPoint) { 
    final float c1 = this.getPerpDotProduct(this.mA, pPoint);
    final float c2 = this.getPerpDotProduct(this.mB, pPoint);
    final float c3 = this.getPerpDotProduct(this.mC, pPoint);

    return ((c1 >= 0 && c2 >= 0 & c3 >= 0) || (c1 <= 0 && c2 <= 0 && c3 <= 0));
}
Run Code Online (Sandbox Code Playgroud)

这是我的考验: 在此输入图像描述

青色区域:我给出的真正三角形.

粉红色区域:"内部"三角形

蓝色区域:"外部"三角形

编辑:

这是我用向量计算的新代码: …

java algorithm collision-detection

6
推荐指数
1
解决办法
426
查看次数

使用多态性以优雅的方式进行碰撞检测

我正在尝试设置一些简单的2D形状,可以使用鼠标在窗口周围拖动.我想让形状在我将其拖入另一个时记录碰撞.我有一个界面.

interface ICollidable
{
    bool CollidedWith(Shape other);
}
Run Code Online (Sandbox Code Playgroud)

然后我有一个抽象类Shape实现上面的接口.

abstract class Shape : ICollidable
{
    protected bool IsPicked { private set; get; }
    protected Form1 Form { private set; get; }

    protected int X { set; get; } // Usually top left X, Y corner point
    protected int Y { set; get; } // Used for drawing using the Graphics object

    protected int CenterX { set; get; } // The center X point of the shape
    protected int CenterY { …
Run Code Online (Sandbox Code Playgroud)

.net c# polymorphism collision-detection

6
推荐指数
1
解决办法
439
查看次数

网格与参数曲面的交点

我想知道如何编写精确的算法来计算参数曲面f : R^2 --> R^3 和三角网格之间交点表面的边界.

我想过第一种方法:

nStepsU = 100
nStepsV = 100
tolerance=0.01 // pick some sensical value
intersectionVertices={}
for  u from minU to maxU in nStepsU:
    for v from minV to maxV in nStepsV:
        for v in verticesInMesh:
             if euclidean distance( f(u,v), v ) < tolerance:
                 add vertex v in a set

connect the vertices in intersectionVertices with a line strip
draw the vertices in intersectionVertices
Run Code Online (Sandbox Code Playgroud)

这个算法非常简单但很慢(n ^ 3)并且没有考虑到网格的地形基于三角形,因此输出点是网格的点而不是利用表面与三角形的交点计算的点并且严重依赖于必须设定的容差.

有人有更好的想法,还是可以为了这个目的把我带到合适的图书馆?

language-agnostic opengl geometry intersection collision-detection

6
推荐指数
1
解决办法
1173
查看次数

Cocos2dx中的像素完美碰撞检测

我试图在Cocos2d-x中移植像素完美碰撞检测,原始版本是为Cocos2D制作的,可以在这里找到:http://www.cocos2d-iphone.org/forums/topic/pixel-perfect-collision-detection -使用色混/

这是我的Cocos2d-x版本的代码

bool CollisionDetection::areTheSpritesColliding(cocos2d::CCSprite *spr1, cocos2d::CCSprite *spr2, bool pp, CCRenderTexture* _rt) {
    bool isColliding = false;
    CCRect intersection;
    CCRect r1 = spr1->boundingBox();
    CCRect r2 = spr2->boundingBox();
    intersection = CCRectMake(fmax(r1.getMinX(),r2.getMinX()), fmax( r1.getMinY(), r2.getMinY()) ,0,0);
    intersection.size.width = fmin(r1.getMaxX(), r2.getMaxX() - intersection.getMinX());
    intersection.size.height = fmin(r1.getMaxY(), r2.getMaxY() - intersection.getMinY());

    // Look for simple bounding box collision
    if ( (intersection.size.width>0) && (intersection.size.height>0) ) {
        // If we're not checking for pixel perfect collisions, return true
        if (!pp) …

c++ collision-detection ios cocos2d-x

6
推荐指数
1
解决办法
4571
查看次数

利用TiledMap进行Libgdx碰撞检测

我正在努力通过平铺地图实现碰撞检测系统.我有一个2D的"口袋妖怪风格"游戏,有一个平铺的地图呈现.具体来说,我的平铺地图.tmx文件中有一个"碰撞"图层,我希望与播放器和其他实体进行交互.我的问题是如何将播放器精灵(扩展Sprite类)连接到平铺贴图的"碰撞"图层并导致两者之间发生碰撞.任何建议表示赞赏.

java collision-detection libgdx

6
推荐指数
1
解决办法
2万
查看次数

如何识别两个图像视图在动画移动时的碰撞?

当两个视图发生碰撞时我正在处理警报,这里我使用了两个在不同方向上移动的图像视图,它们会在一个点上发生碰撞.我使用基本的动画代码在各自的方向上移动这些图像.(注意: - 不仅如下图所示,但是如果它们在方面发生碰撞我们需要显示警报)

在此输入图像描述 在此输入图像描述

objective-c collision-detection uiviewanimation ios

5
推荐指数
2
解决办法
775
查看次数