Skip to content

Weird Rectangle-ConvexPolygon collision result #115

Open
@hayashi-stl

Description

@hayashi-stl

If we define a rectangle and a complex polygon along with their transforms as such:

macro_rules! vec_points {
    ($($points:tt),*) => {
        vec![$(Point2::new $points),*]
    };
}

let r = Rectangle::new(0.75, 1.0);
let p = ConvexPolygon::new(vec_points![(0.5, 0.5), (-0.5, 0.5), (-0.5, -0.5)]);

let r_t = Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.858333333333344, 0.0, 1.0);
let p_t = Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);

and then do an intersection test as such:

let gjk = GJK2::new();
let inter = gjk.intersection(&CollisionStrategy::FullResolution, &r, &r_t, &p, &p_t);
println!("Intersection: {:?}", inter);

the resulting contact is:

Intersection: Some(Contact { strategy: FullResolution, normal: Vector2 [1.0, 0.0], penetration_depth: 1.733333333333344, contact_point: Point2 [0.4904761904761967, 0.5], time_of_impact: 0.0 })

From my previous tests, this should have the normal and contact point on the rectangle, but the normal is pointing right though it is on the left of the rectangle. In addition, the penetration depth is a whopping 1.73, which shouldn't be possible because neither shape is that long.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions