Giter VIP home page Giter VIP logo

Comments (10)

Pomax avatar Pomax commented on September 13, 2024

You're not logging ttList in your console log instruction. You're logging an undefined variable tList. I can highly recommend installing a JS linting extension, or switching your theme, to make sure that undeclared variables are "obviously" highlighted as "this code has a problem even if it'll still run".

from bezierjs.

justvanrossum avatar justvanrossum commented on September 13, 2024

I tried earlier, and the snippet (once the tList/ttList typo is fixed) indeed shows an empty result list, despite that the input curves indeed do visually intersect.

from bezierjs.

ArtOfOmission avatar ArtOfOmission commented on September 13, 2024

thanks for the replay,ttList is alse empty.

from bezierjs.

ArtOfOmission avatar ArtOfOmission commented on September 13, 2024

I tried earlier, and the snippet (once the tList/ttList typo is fixed) indeed shows an empty result list, despite that the input curves indeed do visually intersect.

I updated the code

from bezierjs.

ArtOfOmission avatar ArtOfOmission commented on September 13, 2024

You're not logging ttList in your console log instruction. You're logging an undefined variable tList. I can highly recommend installing a JS linting extension, or switching your theme, to make sure that undeclared variables are "obviously" highlighted as "this code has a problem even if it'll still run".

I updated the code. The variable name is wrong, but the ttList is alse empty.

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

console logging investigation:

    console.log
      running

      at Bezier.intersects (src/bezier.js:848:13)

    console.log
      curveintersects args:

      at Bezier.curveintersects (src/bezier.js:886:13)

    console.log
      c1 [
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: true,
          _lut: [],
          _t1: 0,
          _t2: 0.05158051653718898,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        },
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: true,
          _lut: [],
          _t1: 0.05158051653718898,
          _t2: 0.05455413371263488,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        }
      ]

      at Bezier.curveintersects (src/bezier.js:887:13)

    console.log
      c2 [
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: false,
          _lut: [],
          _t1: 0,
          _t2: 0.09,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        },
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: false,
          _lut: [],
          _t1: 0.09,
          _t2: 1,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        }
      ]

      at Bezier.curveintersects (src/bezier.js:888:13)

    console.log
      initial pairs []

      at Bezier.curveintersects (src/bezier.js:898:13)

    console.log
      intersections []

      at Bezier.curveintersects (src/bezier.js:913:13)

  ● Intersection testing › https://github.com/Pomax/bezierjs/issues/203

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024

Looks like the this.reduce() call in intersects yields a curve set that does not span the full [0,1] interval.

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024
   console.log
      running

      at Bezier.intersects (src/bezier.js:859:13)

    console.log
      first pass reductions: [
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: true,
          _lut: [],
          _t1: 0,
          _t2: 0.05158051653718898,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        },
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: true,
          _lut: [],
          _t1: 0.05158051653718898,
          _t2: 0.05455413371263488,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: false
        },
        Bezier {
          _3d: false,
          points: [ [Object], [Object], [Object], [Object] ],
          order: 3,
          dims: [ 'x', 'y' ],
          dimlen: 2,
          _linear: false,
          _lut: [],
          _t1: 0.05455413371263488,
          _t2: 1,
          dpoints: [ [Array], [Array], [Array] ],
          clockwise: true
        }
      ]

      at Bezier.reduce (src/bezier.js:601:13)

    console.log
      second pass on: Bezier {
        _3d: false,
        points: [
          { x: 20.29469871520996, y: 20.116849899291992 },
          { x: 20.62604239936939, y: 20.550107722706766 },
          { x: 20.95792601544804, y: 20.98468086613082 },
          { x: 21.289809631526694, y: 21.419325704546704 }
        ],
        order: 3,
        dims: [ 'x', 'y' ],
        dimlen: 2,
        _linear: true,
        _lut: [],
        _t1: 0,
        _t2: 0.05158051653718898,
        dpoints: [
          [ [Object], [Object], [Object] ],
          [ [Object], [Object] ],
          [ [Object] ]
        ],
        clockwise: false
      }

      at forEach (src/bezier.js:605:15)
          at Array.forEach (<anonymous>)

    console.log
      t1: 0, t2: 1.0100000000000007

      at forEach (src/bezier.js:629:15)
          at Array.forEach (<anonymous>)

    console.log
      second pass on: Bezier {
        _3d: false,
        points: [
          { x: 21.289809631526694, y: 21.419325704546704 },
          { x: 21.308942724548533, y: 21.44438298282736 },
          { x: 21.328075817570372, y: 21.469440499388 },
          { x: 21.347208807140635, y: 21.49449801594864 }
        ],
        order: 3,
        dims: [ 'x', 'y' ],
        dimlen: 2,
        _linear: true,
        _lut: [],
        _t1: 0.05158051653718898,
        _t2: 0.05455413371263488,
        dpoints: [
          [ [Object], [Object], [Object] ],
          [ [Object], [Object] ],
          [ [Object] ]
        ],
        clockwise: false
      }

      at forEach (src/bezier.js:605:15)
          at Array.forEach (<anonymous>)

    console.log
      t1: 0, t2: 1.0100000000000007

      at forEach (src/bezier.js:629:15)
          at Array.forEach (<anonymous>)

    console.log
      second pass on: Bezier {
        _3d: false,
        points: [
          { x: 21.347208807140635, y: 21.494498015948643 },
          { x: 27.430441729082755, y: 29.46140298519073 },
          { x: 33.50321685100052, y: 37.42830795443282 },
          { x: 36.24053192138672, y: 37.73673629760742 }
        ],
        order: 3,
        dims: [ 'x', 'y' ],
        dimlen: 2,
        _linear: false,
        _lut: [],
        _t1: 0.05455413371263488,
        _t2: 1,
        dpoints: [
          [ [Object], [Object], [Object] ],
          [ [Object], [Object] ],
          [ [Object] ]
        ],
        clockwise: true
      }

      at forEach (src/bezier.js:605:15)
          at Array.forEach (<anonymous>)

from bezierjs.

Pomax avatar Pomax commented on September 13, 2024
    console.log
      second pass on: Bezier {
        _3d: false,
        points: [
          { x: 21.347208807140635, y: 21.494498015948643 },
          { x: 27.430441729082755, y: 29.46140298519073 },
          { x: 33.50321685100052, y: 37.42830795443282 },
          { x: 36.24053192138672, y: 37.73673629760742 }
        ],
        order: 3,
        dims: [ 'x', 'y' ],
        dimlen: 2,
        _linear: false,
        _lut: [],
        _t1: 0.05455413371263488,
        _t2: 1,
        dpoints: [
          [ [Object], [Object], [Object] ],
          [ [Object], [Object] ],
          [ [Object] ]
        ],
        clockwise: true
      }

      at forEach (src/bezier.js:605:15)
          at Array.forEach (<anonymous>)

    console.log
      dead segment for t1:0 and t2:0

Looks like the second pass in the reduction function needs some proper debugging.

from bezierjs.

Undistraction avatar Undistraction commented on September 13, 2024

@Pomax I think I'm seeing the same problem. intersect will correctly detect the intersection most of the time, but occasionally returns an empty array. The most minute change in one of the curves can result in no intersections, and happens for cases where the intersection is obvious between two curves that simply cross (i.e. intersections aren't end points, and curves don't cross multiple times). I can provide an interactive page that will allow to easily replicate the issue if that would be helpful.

from bezierjs.

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.