geometrygeometry-surfacegeometric-arc

How can I find the steepest point of curve or the arc of the curvature?


Given the curve I just have the (X,Y) coordinates of the curve, I want to find the steepest point of this curve or the arc length (starting and ending point of the arc)


Solution

  • If you have a collection of points which you are drawing straight lines between, it is a polygon and the points of a polyon don't have a slope because the slope of the line on one side of the point is usually not the same as the slope of the line on the other side of the point. You can get the slope between the points, which is what the code below does. (This is javascript because you didn't specify a language)

    var pointsArray = [[0,0],[5,13],[10,19],[15,14],[20,-3]];
    
    function findSlopes(points) {
        var result = [];
        for (i = 0; i < points.length - 1; i++) {
            var rise = points[i+1][1] - points[i][1];
            var run = points[i+1][0] - points[i][0];
            result.push(rise / run);
        }
        return result;
    }
    
    var slopesArray = findSlopes(pointsArray);
    
    console.log("slopes " + slopesArray);
    

    To find the steepest slope, step through the slopes array to find the highest absolute value.

    function steepestSlope(slopes) {
        var steepestValue = 0;
        var steepestIndex = -1;
        for (var i = 0; i < slopes.length; i++) {
            if (Math.abs(slopes[i]) > Math.abs(steepestValue)) {
                steepestValue = slopes[i];
                steepestIndex = i;
            }
        }
        return steepestIndex;
    }
    
    var steepest = steepestSlope(slopesArray);
    
    console.log("steepest " + steepest);
    

    The code below finds the total length of the polygon represented by the points.

    function findLength(points) {
        var result = 0;
        for (i = 0; i < points.length - 1; i++) {
            var dx = points[i+1][0] - points[i][0];
            var dy = points[i+1][1] - points[i][1];
            result += Math.sqrt(dx * dx + dy * dy);
        }
        return result;
    }
    var length = findLength(pointsArray);
    
    console.log("length " + length);
    

    If you are using something other than straight lines to join the points, like a spline curve, then the points do have curvature and the math is more complicated.