Code Monkey home page Code Monkey logo

kld-polynomial's People

Contributors

brettz9 avatar pboyer avatar quazistax avatar thelonious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kld-polynomial's Issues

Intersecting two adjacent sections of a subdivided cubic bezier can produce an empty Polynomial

I subdivided a cubic bezier and created the two following cubic beziers:

const a = [
  { x: 162.48848597698444, y: 112.35319657757165 },
  { x: 163.95162031178776, y: 116.41373265436673 },
  { x: 165.52010700334841, y: 120.60494234401577 },
  { x: 167.20635691757136, y: 124.93096260181979 },
];

const b = [
  { x: 167.20635691757136, y: 124.93096260181979 },
  { x: 171.54020965581395, y: 136.04932328005688 },
  { x: 176.651945072729, y: 148.0581725463195 },
  { x: 182.75226034297538, y: 161.02774279216203 },
];

Running these beziers through intersectBezier3Bezier3 will produce this Polynomial.

var poly = new Polynomial(
  8.282089296964086e-38,
  1.3395768780405303e-26,
  7.222276683850399e-16,
  1.4410533333746558e-14,
  1.4180955129790285e-13,
  4.0776756971006023e-13,
  -1.3752193828153736e-13,
  -7.466249840604178e-14,
  -6.794564910705958e-14,
  -4.551914400963142e-15,
);

Calling poly.simplify() will result in a polynomial with the coefs being an empty array.

I'm not going to pretend to understand the math behind Polynomials, but in 61e809c, an empty Polynomial is referred to as unexpected. What makes an empty Polynomial unexpected?

I consistently run into this issue when intersecting different beziers that are the result of a bezier subdivision, but haven't seen this happen under any other circumstances.

Workaround

My current workaround this issue is:

var droots = this.getDegree() > 0
  ? deriv.getRootsInInterval(min, max)
  : [];

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.