Coder Social home page Coder Social logo

Comments (3)

elsid avatar elsid commented on August 29, 2024

Not sure is it related but time_of_impact is not commutative for Ball and Segment. If ball* and segment* arguments are swapped in time_of_impact_should_return_toi_for_ball_and_rotated_segment then the test does not pass because time_of_impact returns None:

#[test]
fn time_of_impact_should_return_toi_for_rotated_segment_and_ball() {
    let ball_isometry = Isometry2::identity();
    let ball_velocity = Vector2::new(1.0, 0.0);
    let ball = Ball::new(0.5);
    let segment_isometry = Isometry2::rotation(-std::f32::consts::FRAC_PI_2);
    let segment_velocity = Vector2::zeros();
    let segment = Segment::new(Point2::new(1.0, 1.0), Point2::new(-1.0, 1.0));

    assert_eq!(segment_isometry.transform_point(&Point2::new(1.0, 1.0)), Point2::new(0.99999994, -1.0));
    assert_eq!(segment_isometry.transform_point(&Point2::new(-1.0, 1.0)), Point2::new(1.0, 0.99999994));

    let toi = query::time_of_impact(
        &segment_isometry, &segment_velocity, &segment,
        &ball_isometry, &ball_velocity, &ball,
        1.0, 0.0,
    ).unwrap();

    assert_eq!(toi.unwrap().toi, 0.49999994);
}

from parry.

elsid avatar elsid commented on August 29, 2024

The same tests are passing with ncollide. The main difference I see between these libraries is an attempt to use only one transformation and velocity in parry:

let pos12 = pos1.inv_mul(pos2);
let vel12 = vel2 - vel1;
.

from parry.

sebcrozet avatar sebcrozet commented on August 29, 2024

Thank you for the test cases! You are correct, there is a bug as it should be let vel12 = pos1.inverse_transform_vector(&(vel2 - vel1)) because the velocity must be expressed in the local-space of the first shape.

This will be fixed at part of today's release.

from parry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.