davideberly / GeometricTools

A collection of source code for computing in the fields of mathematics, geometry, graphics, image analysis and physics.
Boost Software License 1.0
1.14k stars 214 forks source link

FIQuery<T, Line2<T>, Line2<T>> result wrong. #49

Closed sonygod closed 1 year ago

sonygod commented 1 year ago

the result point should be [2.0,2.0] but got [-2.0,-2.0]

  Line2<float_t> line2_3({0.0, 0.0}, {0.5, 0.5});

    Line2<float_t> line2_4({2.0, 0.0}, {2.0, 1.0});

   IntrPointLine2AndLine2<float_t> intrLine2AndLine2;

    auto result6 = intrLine2AndLine2(line2_3, line2_4);

   Vector2<float_t> respect = {2.0f, 2.0f};
    assert(result6.point == respect);
image
sonygod commented 1 year ago

Tests whether parallel lines intersect fail.

 Line2<float_t> line2_5({0.0, 0.0}, {1.0, 0.0});

    Line2<float_t> line2_6({0.0, 1.0}, {1.0, 1.0});

    IntrPointLine2AndLine2<float_t> intrLine2AndLine2_2;

    auto result7 = intrLine2AndLine2_2(line2_5, line2_6);

    assert(result7.intersect == false);
image
owai1980 commented 1 year ago

Hello, I'm not sure, but I think the line2 objects are not defined by 2 points, but 1 point + direction unit vector. (distance between the two points must be "1")

So... If your lines are not well defined, ofc the result is bad...

(this is just my opinion)

Le sam. 3 déc. 2022 à 09:16, Mr zhan @.***> a écrit :

Tests whether parallel lines intersect fail.

Line2 line2_5({0.0, 0.0}, {1.0, 0.0});

Line2<float_t> line2_6({0.0, 1.0}, {1.0, 1.0});

IntrPointLine2AndLine2<float_t> intrLine2AndLine2_2;

auto result7 = intrLine2AndLine2_2(line2_5, line2_6);

assert(result7.intersect == false);

— Reply to this email directly, view it on GitHub https://github.com/davideberly/GeometricTools/issues/49#issuecomment-1336111607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG3BAQMFLKEP2CKTMTYXOJDWLL6W3ANCNFSM6AAAAAASSTTRD4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

sonygod commented 1 year ago

thanks, yes, line 2 is defined by 1 point and direction instead of two points.