Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. HOW TO DISTINGUISE POINTS OF LINES AND CURVES ???

HOW TO DISTINGUISE POINTS OF LINES AND CURVES ???

Scheduled Pinned Locked Moved .NET (Core and Framework)
tutorialgraphicsquestion
10 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TARAK NATH ROY
    wrote on last edited by
    #1

    I have dictionary of x and y cordinates and with this cordinate i have drawn a polygon.After drawing the ploygon it is now combination of Lines And Curves. Can any one guide me how to segregate points of dictionary that I can understand these points are for Line and those points are for Curves. with regards tarak

    M 1 Reply Last reply
    0
    • T TARAK NATH ROY

      I have dictionary of x and y cordinates and with this cordinate i have drawn a polygon.After drawing the ploygon it is now combination of Lines And Curves. Can any one guide me how to segregate points of dictionary that I can understand these points are for Line and those points are for Curves. with regards tarak

      M Offline
      M Offline
      molesworth
      wrote on last edited by
      #2

      I'm not sure I understand the problem. Surely, if you're drawing the lines and curves you know which points you've used for each, and can save that information.

      There are three kinds of people in the world - those who can count and those who can't...

      T 1 Reply Last reply
      0
      • M molesworth

        I'm not sure I understand the problem. Surely, if you're drawing the lines and curves you know which points you've used for each, and can save that information.

        There are three kinds of people in the world - those who can count and those who can't...

        T Offline
        T Offline
        TARAK NATH ROY
        wrote on last edited by
        #3

        hiii molesworth The drawing of polygon is in very later stage. My aim is by visualizing the neighbouring point how can i under stand these set of points will be in straight line and those set of points will be in curve????

        M 1 Reply Last reply
        0
        • T TARAK NATH ROY

          hiii molesworth The drawing of polygon is in very later stage. My aim is by visualizing the neighbouring point how can i under stand these set of points will be in straight line and those set of points will be in curve????

          M Offline
          M Offline
          molesworth
          wrote on last edited by
          #4

          Ah, I think I understand. You want to draw a line when the points are on a line (or close to it) and a curve of some sort otherwise. The simplest way that comes to mind is to calculate the slope of the line segments between pairs of points and if all the slopes are equal (within some reasonable limits) then the points lie on a straight line.

          There are three kinds of people in the world - those who can count and those who can't...

          T 1 Reply Last reply
          0
          • M molesworth

            Ah, I think I understand. You want to draw a line when the points are on a line (or close to it) and a curve of some sort otherwise. The simplest way that comes to mind is to calculate the slope of the line segments between pairs of points and if all the slopes are equal (within some reasonable limits) then the points lie on a straight line.

            There are three kinds of people in the world - those who can count and those who can't...

            T Offline
            T Offline
            TARAK NATH ROY
            wrote on last edited by
            #5

            hi molesworth thanx for reply.

            T 1 Reply Last reply
            0
            • T TARAK NATH ROY

              hi molesworth thanx for reply.

              T Offline
              T Offline
              TARAK NATH ROY
              wrote on last edited by
              #6

              hi molesworth thanx for reply But there may be lots of line in various direction..in that case how the slope is same for every line??

              M 1 Reply Last reply
              0
              • T TARAK NATH ROY

                hi molesworth thanx for reply But there may be lots of line in various direction..in that case how the slope is same for every line??

                M Offline
                M Offline
                molesworth
                wrote on last edited by
                #7

                It seems I've misunderstood your problem. I was guessing from the description that you had a number of points (x,y) and wanted to draw lines through them. If the points lie on a straight line, then you want to draw only that straight line through them, but if they don't then you want to draw a curve through them. Perhaps you can explain with a bit more detail what you are trying to do.

                There are three kinds of people in the world - those who can count and those who can't...

                T 1 Reply Last reply
                0
                • M molesworth

                  It seems I've misunderstood your problem. I was guessing from the description that you had a number of points (x,y) and wanted to draw lines through them. If the points lie on a straight line, then you want to draw only that straight line through them, but if they don't then you want to draw a curve through them. Perhaps you can explain with a bit more detail what you are trying to do.

                  There are three kinds of people in the world - those who can count and those who can't...

                  T Offline
                  T Offline
                  TARAK NATH ROY
                  wrote on last edited by
                  #8

                  Mr.molesworth thanx for reply yes u are right that i have number of points(x,y) near about 1000.If i plot all these points in graph paper then it looks like a polygon.And polygon is combination of lots of curve and lines. And in curve there are lot of combination of small length of straight line.Basicaly if i join two point it becomes straight line. And in curve the each small straight lines bend very slightly and it appears in graph like a curve. But i dont want to plot these point on the graph paper. Only i have set of points(x,y). How can i calculate that some set of points will be used for drawing one or more than one curve and other set of points will be used for drawing the line or lines.. awaiting for ur reply....

                  M 2 Replies Last reply
                  0
                  • T TARAK NATH ROY

                    Mr.molesworth thanx for reply yes u are right that i have number of points(x,y) near about 1000.If i plot all these points in graph paper then it looks like a polygon.And polygon is combination of lots of curve and lines. And in curve there are lot of combination of small length of straight line.Basicaly if i join two point it becomes straight line. And in curve the each small straight lines bend very slightly and it appears in graph like a curve. But i dont want to plot these point on the graph paper. Only i have set of points(x,y). How can i calculate that some set of points will be used for drawing one or more than one curve and other set of points will be used for drawing the line or lines.. awaiting for ur reply....

                    M Offline
                    M Offline
                    molesworth
                    wrote on last edited by
                    #9

                    TARAK NATH ROY wrote:

                    i have number of points(x,y) near about 1000.If i plot all these points in graph paper then it looks like a polygon.And polygon is combination of lots of curve and lines

                    OK, I think I understand a bit better now. You have a large list of points, and want to draw a figure from them, using straight lines and curves to best fit the shape. Although to be technically correct, a polygon is a shape made of only straight lines, I get what you mean. So, you need to go through the list, finding the sections which are best drawn as straight lines, and which are best as curves. My previous suggestion about matching slopes is probably still a reasonable way to try, but over limited ranges of points. If you calculate the slope between points (Xn, Yn) and (Xn+1, Yn+1) as (Yn+1 - Yn) / (Xn+1 - Xn) then you can compare the slope values as you step through the list (increasing n). If consecutive slopes are equal, or better, if the difference between them is less than some small constant, then the group of points are all very close to being a straight line. If you get a change in slope, greater than your limit value, then you've entered a curve region. As you go through the points you can either copy them to separate line and curve lists, or possibly note the indices where the type of line changes. Drawing the straight lines is easy, however you may have to look at your data more closely to find the best curve drawing method to give a good match. Here's a rough pseudo-code version of what I'm describing above :-

                    lastSlope = 0;
                    
                    for (int n=0; n<numPoints; ++n)
                    {
                        // need to check for dX == 0  and handle array overrun
                        slope = (Y\[n+1\] - Y\[n\]) / (X\[n+1\] - X\[n\]);
                    
                        if (abs(slope - lastSlope) < smallValue)
                        {
                            // now in straight line region
                            // add points to straight line list
                        }
                        else
                        {
                            // now in curve region
                            // add points to curve list
                        }
                    
                        lastSlope = slope;
                    }
                    

                    I hope that helps you a bit... :)

                    There are three kinds of people in the world - those who can count and those who can't...

                    1 Reply Last reply
                    0
                    • T TARAK NATH ROY

                      Mr.molesworth thanx for reply yes u are right that i have number of points(x,y) near about 1000.If i plot all these points in graph paper then it looks like a polygon.And polygon is combination of lots of curve and lines. And in curve there are lot of combination of small length of straight line.Basicaly if i join two point it becomes straight line. And in curve the each small straight lines bend very slightly and it appears in graph like a curve. But i dont want to plot these point on the graph paper. Only i have set of points(x,y). How can i calculate that some set of points will be used for drawing one or more than one curve and other set of points will be used for drawing the line or lines.. awaiting for ur reply....

                      M Offline
                      M Offline
                      molesworth
                      wrote on last edited by
                      #10

                      As an alternative to my last post, you could always try just drawing straight lines between the points, and seeing what it looks like. I have an audio waveform display in the project I'm currently working on, and I just join all the sample values with straight lines, which looks fine since there are so many of them in the view. You might get away with just doing that...

                      There are three kinds of people in the world - those who can count and those who can't...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups