Search Unity

Comparing curviness between two curves that are made with points

Discussion in 'Scripting' started by eyeofhorus, Feb 3, 2017.

  1. eyeofhorus

    eyeofhorus

    Joined:
    Oct 10, 2013
    Posts:
    10
    I have two set of points [x,y] that forms a "curve"

    How can i determine the "curviness" of a curve? As shown in the diagram, curve 2 is more curvy than curve 1.

    I'm thinking to derive some kind of normalized value to compare the curviness.

    16492590_10155061744474783_1782171322_o.jpg
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. eyeofhorus

    eyeofhorus

    Joined:
    Oct 10, 2013
    Posts:
    10
    yes, my approach is to calculate the angle between each set of three points, and average them out.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You are talking about the derivatives. So basic calculus stuff.

    The first derivative tells you the slope of the line. Which is not expecially useful for your problem.

    The second derivative tells you how fast the slope is changing. Which seems to meet your problem definition well. A high positive number means the line is curving up. A high negative number means the line is curving down. And a zero means the line is not curving.
     
    lordofduct likes this.
  5. eyeofhorus

    eyeofhorus

    Joined:
    Oct 10, 2013
    Posts:
    10
    however my curves are not continuous, they are consist a few discrete points, say an array of five vec2 [x,y]
     
  6. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    Add them and the larger absolute value is "more curvy" as @BoredMormon explains.
     
  7. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    So what? Use discrete methods to get the absolute value of the derivative.