function draw_line(current_particle) {
    for (var k = 0; k <= particle_array.length - 1; k++) {
        //using the distance formula to calculate the line distance
        line_distance = Math.sqrt((Math.pow((particle_array[k].x_pos - current_particle.x_pos),2) + Math.pow((particle_array[k].y_pos - current_particle.y_pos),2)));
        //testing the current particle against all other particles to see if they are within range
        if (line_distance < line_distance_threshold) {
            rand_color = Math.floor(Math.random() * color_array.length);
            ctx.strokeStyle = "orange";
            ctx.beginPath();
            ctx.moveTo(current_particle.x_pos, current_particle.y_pos);
            //drawing the line
            ctx.lineTo(particle_array[k].x_pos, particle_array[k].y_pos);
            ctx.closePath();
            ctx.stroke();
        }
    }
}
//this function is responsible for detecting whether particles fall within line drawing distance and drawing the line
this function is responsible for detecting whether particles fall within line drawing distance and drawing the line
this function is responsible for detecting whether particles fall within line drawing distance and drawing the line
function draw_line(current_particle) {
    for (var k = 0; k <= particle_array.length - 1; k++) {
        line_distance = Math.sqrt((Math.pow((particle_array[k].x_pos - current_particle.x_pos),2) + Math.pow((particle_array[k].y_pos - current_particle.y_pos),2)));
        if (line_distance < line_distance_threshold) {
            rand_color = Math.floor(Math.random() * color_array.length);
            ctx.strokeStyle = "orange";
            ctx.beginPath();
            ctx.moveTo(current_particle.x_pos, current_particle.y_pos);
            ctx.lineTo(particle_array[k].x_pos, particle_array[k].y_pos);
            ctx.closePath();
            ctx.stroke();
        }
    }
}
function draw_line ( current_particle ) { for ( var k = 0 ; k <= particle_array . length - 1 ; k ++ ) { line_distance = Math . sqrt ( ( Math . pow ( ( particle_array [ k ] . x_pos - current_particle . x_pos ) , 2 ) + Math . pow ( ( particle_array [ k ] . y_pos - current_particle . y_pos ) , 2 ) ) ) ; if ( line_distance < line_distance_threshold ) { rand_color = Math . floor ( Math . random ( ) * color_array . length ) ; ctx . strokeStyle = "orange" ; ctx . beginPath ( ) ; ctx . moveTo ( current_particle . x_pos , current_particle . y_pos ) ; ctx . lineTo ( particle_array [ k ] . x_pos , particle_array [ k ] . y_pos ) ; ctx . closePath ( ) ; ctx . stroke ( ) ; } } }
this function is responsible for detecting whether particles fall within line drawing distance and drawing the line
this function is responsible for detecting whether particles fall within line drawing distance and drawing the line
//using the distance formula to calculate the line distance //testing the current particle against all other particles to see if they are within range //drawing the line