pub fn jarvis_march(input_set: &mut Vec<Point2D>) -> Vec<Point2D> {
    let sorted_input_set = input_set;

    let mut last_known_hull_point = sorted_input_set[0];
    //initialize the stack that will maintain the candidate points
    let mut hull_points: Vec<Point2D> = Vec::new();
    hull_points.push(last_known_hull_point);
    for _i in 0..sorted_input_set.len() {
        let p_i = last_known_hull_point;
        let mut end_point = sorted_input_set[0];
        for j in 1..sorted_input_set.len() {
            if end_point == last_known_hull_point 
                            || sorted_input_set[j].ccw(&p_i, &end_point) {
                end_point = sorted_input_set[j];
            }
        }
        if end_point == hull_points[0] {
            break;
        }
        hull_points.push(end_point);
        last_known_hull_point = end_point;
    }
    hull_points
}
/// Solves the convexhull problem using Jarvis-March
///
/// The psedocode for this algorithm is referred from
/// Introduction to Algorithms (Third Edition)
/// Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein
Solves the convexhull problem using Jarvis-March
The psedocode for this algorithm is referred from
Introduction to Algorithms (Third Edition)
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein
Solves the convexhull problem using Jarvis - March The psedocode for this algorithm is referred from Introduction to Algorithms ( Third Edition ) Authors : Thomas H . Cormen Charles E . Leiserson Ronald L . Rivest and Clifford Stein
pub fn jarvis_march(input_set: &mut Vec<Point2D>) -> Vec<Point2D> {
    let sorted_input_set = input_set;
    let mut last_known_hull_point = sorted_input_set[0];
    //initialize the stack that will maintain the candidate points
    let mut hull_points: Vec<Point2D> = Vec::new();
    hull_points.push(last_known_hull_point);
    for _i in 0..sorted_input_set.len() {
        let p_i = last_known_hull_point;
        let mut end_point = sorted_input_set[0];
        for j in 1..sorted_input_set.len() {
            if end_point == last_known_hull_point 
                            || sorted_input_set[j].ccw(&p_i, &end_point) {
                end_point = sorted_input_set[j];
            }
        }
        if end_point == hull_points[0] {
            break;
        }
        hull_points.push(end_point);
        last_known_hull_point = end_point;
    }
    hull_points
}
pub fn jarvis_march ( input_set : & mut Vec < Point2D > ) -> Vec < Point2D > { let sorted_input_set = input_set ; let mut last_known_hull_point = sorted_input_set [ 0 ] ; //initialize the stack that will maintain the candidate points let mut hull_points : Vec < Point2D > = Vec :: new ( ) ; hull_points . push ( last_known_hull_point ) ; for _i in 0 .. sorted_input_set . len ( ) { let p_i = last_known_hull_point ; let mut end_point = sorted_input_set [ 0 ] ; for j in 1 .. sorted_input_set . len ( ) { if end_point == last_known_hull_point || sorted_input_set [ j ] . ccw ( & p_i , & end_point ) { end_point = sorted_input_set [ j ] ; } } if end_point == hull_points [ 0 ] { break ; } hull_points . push ( end_point ) ; last_known_hull_point = end_point ; } hull_points }
Solves the convexhull problem using Jarvis-March
The psedocode for this algorithm is referred from
Introduction to Algorithms (Third Edition)
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein
Solves the convexhull problem using Jarvis - March The psedocode for this algorithm is referred from Introduction to Algorithms ( Third Edition ) Authors : Thomas H . Cormen Charles E . Leiserson Ronald L . Rivest and Clifford Stein
input_set
&mut Vec<Point2D>
input_set
&mut Vec<Point2D>