pub fn discretize(
        point: &Point<I>,
        segment: &Line<I>,
        max_dist: F,
        affine: &SimpleAffine<I, F>,
        discretization: &mut Vec<[F; 2]>,
    ) {
        // no need to discretize infinitely small distances
        if discretization[0][0] == discretization[1][0]
            && discretization[0][1] == discretization[1][1]
        {
            return;
        }
        // Apply the linear transformation to move start point of the segment to
        // the point with coordinates (0, 0) and the direction of the segment to
        // coincide the positive direction of the x-axis.
        let segm_vec_x: F =
            affine.transform_ix(segment.end.x) - affine.transform_ix(segment.start.x);
        let segm_vec_y: F =
            affine.transform_iy(segment.end.y) - affine.transform_iy(segment.start.y);
        let sqr_segment_length = segm_vec_x * segm_vec_x + segm_vec_y * segm_vec_y;

        // Compute x-coordinates of the endpoints of the edge
        // in the transformed space.
        let projection_start =
            sqr_segment_length * Self::get_point_projection(affine, &discretization[0], segment);
        let projection_end =
            sqr_segment_length * Self::get_point_projection(affine, &discretization[1], segment);

        // Compute parabola parameters in the transformed space.
        // Parabola has next representation:
        // f(x) = ((x-rot_x)^2 + rot_y^2) / (2.0*rot_y).
        let point_vec_x = affine.transform_ix(point.x) - affine.transform_ix(segment.start.x);
        let point_vec_y = affine.transform_iy(point.y) - affine.transform_iy(segment.start.y);
        let rot_x = segm_vec_x * point_vec_x + segm_vec_y * point_vec_y;
        let rot_y = segm_vec_x * point_vec_y - segm_vec_y * point_vec_x;

        // Save the last point.
        let last_point = (*discretization)[1];
        let _ = discretization.pop();

        // Use stack to avoid recursion.
        let mut point_stack = vec![projection_end];
        let mut cur_x = projection_start;
        let mut cur_y = Self::parabola_y(cur_x, rot_x, rot_y);

        // Adjust max_dist parameter in the transformed space.
        let max_dist_transformed = max_dist * max_dist * sqr_segment_length;
        while !point_stack.is_empty() {
            let new_x = point_stack[point_stack.len() - 1]; // was .top();
            let new_y = Self::parabola_y(new_x, rot_x, rot_y);

            // Compute coordinates of the point of the parabola that is
            // furthest from the current line segment.
            let mid_x = (new_y - cur_y) / (new_x - cur_x) * rot_y + rot_x;
            let mid_y = Self::parabola_y(mid_x, rot_x, rot_y);

            // Compute maximum distance between the given parabolic arc
            // and line segment that discretize it.
            let mut dist = (new_y - cur_y) * (mid_x - cur_x) - (new_x - cur_x) * (mid_y - cur_y);
            #[allow(clippy::suspicious_operation_groupings)]
            {
                dist = dist * dist
                    / ((new_y - cur_y) * (new_y - cur_y) + (new_x - cur_x) * (new_x - cur_x));
            }
            if dist.is_nan() {
                break;
            }
            if dist <= max_dist_transformed {
                // Distance between parabola and line segment is less than max_dist.
                let _ = point_stack.pop();
                let inter_x = (segm_vec_x * new_x - segm_vec_y * new_y) / sqr_segment_length
                    + affine.transform_ix(segment.start.x);
                let inter_y = (segm_vec_x * new_y + segm_vec_y * new_x) / sqr_segment_length
                    + affine.transform_iy(segment.start.y);
                discretization.push([inter_x, inter_y]);
                cur_x = new_x;
                cur_y = new_y;
            } else {
                point_stack.push(mid_x);
            }
        }
        // Update last point.
        let discretization_len = discretization.len();
        discretization[discretization_len - 1] = last_point;
    }
/// Discretize parabolic Voronoi edge.
/// Parabolic Voronoi edges are always formed by one point and one segment
/// from the initial input set.
///
/// Args:
///   point: input point in diagram coordinate system
///   segment: input segment in diagram coordinate system
///   max_dist: maximum discretization distance in output coordinate system,
///   affine: an affine transform converting from diagram coordinate system to output coordinate system,
///   discretization: point discretization of the given Voronoi edge in output coordinate system,
///
/// Template arguments:
///   InCT: coordinate type of the input geometries (usually integer).
///   Point: point type, should model point concept.
///   Segment: segment type, should model segment concept.
///
/// Important:
///   discretization should contain both edge endpoints initially.
Discretize parabolic Voronoi edge.
Parabolic Voronoi edges are always formed by one point and one segment
from the initial input set.

input point in diagram coordinate system
segment: input segment in diagram coordinate system
max_dist: maximum discretization distance in output coordinate system,
affine: an affine transform converting from diagram coordinate system to output coordinate system,
discretization: point discretization of the given Voronoi edge in output coordinate system.

Template arguments:
InCT: coordinate type of the input geometries (usually integer).
Point: point type, should model point concept.
Segment: segment type, should model segment concept.

discretization should contain both edge endpoints initially.
Discretize parabolic Voronoi edge . Parabolic Voronoi edges are always formed by one point and one segment from the initial input set . input point in diagram coordinate system segment : input segment in diagram coordinate system max_dist : maximum discretization distance in output coordinate system affine : an affine transform converting from diagram coordinate system to output coordinate system discretization : point discretization of the given Voronoi edge in output coordinate system . Template arguments : InCT : coordinate type of the input geometries ( usually integer ) . Point : point type should model point concept . Segment : segment type should model segment concept . discretization should contain both edge endpoints initially .
pub fn discretize(
        point: &Point<I>,
        segment: &Line<I>,
        max_dist: F,
        affine: &SimpleAffine<I, F>,
        discretization: &mut Vec<[F; 2]>,
    ) {
        // no need to discretize infinitely small distances
        if discretization[0][0] == discretization[1][0]
            && discretization[0][1] == discretization[1][1]
        {
            return;
        }
        // Apply the linear transformation to move start point of the segment to
        // the point with coordinates (0, 0) and the direction of the segment to
        // coincide the positive direction of the x-axis.
        let segm_vec_x: F =
            affine.transform_ix(segment.end.x) - affine.transform_ix(segment.start.x);
        let segm_vec_y: F =
            affine.transform_iy(segment.end.y) - affine.transform_iy(segment.start.y);
        let sqr_segment_length = segm_vec_x * segm_vec_x + segm_vec_y * segm_vec_y;
        // Compute x-coordinates of the endpoints of the edge
        // in the transformed space.
        let projection_start =
            sqr_segment_length * Self::get_point_projection(affine, &discretization[0], segment);
        let projection_end =
            sqr_segment_length * Self::get_point_projection(affine, &discretization[1], segment);
        // Compute parabola parameters in the transformed space.
        // Parabola has next representation:
        // f(x) = ((x-rot_x)^2 + rot_y^2) / (2.0*rot_y).
        let point_vec_x = affine.transform_ix(point.x) - affine.transform_ix(segment.start.x);
        let point_vec_y = affine.transform_iy(point.y) - affine.transform_iy(segment.start.y);
        let rot_x = segm_vec_x * point_vec_x + segm_vec_y * point_vec_y;
        let rot_y = segm_vec_x * point_vec_y - segm_vec_y * point_vec_x;
        // Save the last point.
        let last_point = (*discretization)[1];
        let _ = discretization.pop();
        // Use stack to avoid recursion.
        let mut point_stack = vec![projection_end];
        let mut cur_x = projection_start;
        let mut cur_y = Self::parabola_y(cur_x, rot_x, rot_y);
        // Adjust max_dist parameter in the transformed space.
        let max_dist_transformed = max_dist * max_dist * sqr_segment_length;
        while !point_stack.is_empty() {
            let new_x = point_stack[point_stack.len() - 1]; // was .top();
            let new_y = Self::parabola_y(new_x, rot_x, rot_y);
            // Compute coordinates of the point of the parabola that is
            // furthest from the current line segment.
            let mid_x = (new_y - cur_y) / (new_x - cur_x) * rot_y + rot_x;
            let mid_y = Self::parabola_y(mid_x, rot_x, rot_y);
            // Compute maximum distance between the given parabolic arc
            // and line segment that discretize it.
            let mut dist = (new_y - cur_y) * (mid_x - cur_x) - (new_x - cur_x) * (mid_y - cur_y);
            #[allow(clippy::suspicious_operation_groupings)]
            {
                dist = dist * dist
                    / ((new_y - cur_y) * (new_y - cur_y) + (new_x - cur_x) * (new_x - cur_x));
            }
            if dist.is_nan() {
                break;
            }
            if dist <= max_dist_transformed {
                // Distance between parabola and line segment is less than max_dist.
                let _ = point_stack.pop();
                let inter_x = (segm_vec_x * new_x - segm_vec_y * new_y) / sqr_segment_length
                    + affine.transform_ix(segment.start.x);
                let inter_y = (segm_vec_x * new_y + segm_vec_y * new_x) / sqr_segment_length
                    + affine.transform_iy(segment.start.y);
                discretization.push([inter_x, inter_y]);
                cur_x = new_x;
                cur_y = new_y;
            } else {
                point_stack.push(mid_x);
            }
        }
        // Update last point.
        let discretization_len = discretization.len();
        discretization[discretization_len - 1] = last_point;
    }
pub fn discretize ( point : & Point < I > , segment : & Line < I > , max_dist : F , affine : & SimpleAffine < I , F > , discretization : & mut Vec < [ F ; 2 ] > , ) { // no need to discretize infinitely small distances if discretization [ 0 ] [ 0 ] == discretization [ 1 ] [ 0 ] && discretization [ 0 ] [ 1 ] == discretization [ 1 ] [ 1 ] { return ; } // Apply the linear transformation to move start point of the segment to // the point with coordinates (0, 0) and the direction of the segment to // coincide the positive direction of the x-axis. let segm_vec_x : F = affine . transform_ix ( segment . end . x ) - affine . transform_ix ( segment . start . x ) ; let segm_vec_y : F = affine . transform_iy ( segment . end . y ) - affine . transform_iy ( segment . start . y ) ; let sqr_segment_length = segm_vec_x * segm_vec_x + segm_vec_y * segm_vec_y ; // Compute x-coordinates of the endpoints of the edge // in the transformed space. let projection_start = sqr_segment_length * Self :: get_point_projection ( affine , & discretization [ 0 ] , segment ) ; let projection_end = sqr_segment_length * Self :: get_point_projection ( affine , & discretization [ 1 ] , segment ) ; // Compute parabola parameters in the transformed space. // Parabola has next representation: // f(x) = ((x-rot_x)^2 + rot_y^2) / (2.0*rot_y). let point_vec_x = affine . transform_ix ( point . x ) - affine . transform_ix ( segment . start . x ) ; let point_vec_y = affine . transform_iy ( point . y ) - affine . transform_iy ( segment . start . y ) ; let rot_x = segm_vec_x * point_vec_x + segm_vec_y * point_vec_y ; let rot_y = segm_vec_x * point_vec_y - segm_vec_y * point_vec_x ; // Save the last point. let last_point = ( * discretization ) [ 1 ] ; let _ = discretization . pop ( ) ; // Use stack to avoid recursion. let mut point_stack = vec ! [ projection_end ] ; let mut cur_x = projection_start ; let mut cur_y = Self :: parabola_y ( cur_x , rot_x , rot_y ) ; // Adjust max_dist parameter in the transformed space. let max_dist_transformed = max_dist * max_dist * sqr_segment_length ; while ! point_stack . is_empty ( ) { let new_x = point_stack [ point_stack . len ( ) - 1 ] ; // was .top(); let new_y = Self :: parabola_y ( new_x , rot_x , rot_y ) ; // Compute coordinates of the point of the parabola that is // furthest from the current line segment. let mid_x = ( new_y - cur_y ) / ( new_x - cur_x ) * rot_y + rot_x ; let mid_y = Self :: parabola_y ( mid_x , rot_x , rot_y ) ; // Compute maximum distance between the given parabolic arc // and line segment that discretize it. let mut dist = ( new_y - cur_y ) * ( mid_x - cur_x ) - ( new_x - cur_x ) * ( mid_y - cur_y ) ; # [ allow ( clippy suspicious_operation_groupings ) ] { dist = dist * dist / ( ( new_y - cur_y ) * ( new_y - cur_y ) + ( new_x - cur_x ) * ( new_x - cur_x ) ) ; } if dist . is_nan ( ) { break ; } if dist <= max_dist_transformed { // Distance between parabola and line segment is less than max_dist. let _ = point_stack . pop ( ) ; let inter_x = ( segm_vec_x * new_x - segm_vec_y * new_y ) / sqr_segment_length + affine . transform_ix ( segment . start . x ) ; let inter_y = ( segm_vec_x * new_y + segm_vec_y * new_x ) / sqr_segment_length + affine . transform_iy ( segment . start . y ) ; discretization . push ( [ inter_x , inter_y ] ) ; cur_x = new_x ; cur_y = new_y ; } else { point_stack . push ( mid_x ) ; } } // Update last point. let discretization_len = discretization . len ( ) ; discretization [ discretization_len - 1 ] = last_point ; }
Discretize parabolic Voronoi edge.
Discretize parabolic Voronoi edge .
point
&Point<I>
segment
&Line<I>
max_dist
F
affine
&SimpleAffine<I, F>
discretization
&mut Vec<[F; 2]>