Skip to contents

This function calculates the 2D distances between pairs of points in a data frame.

Usage

cal_2d_dist(
  .data,
  start_x = "x_from",
  start_y = "y_from",
  end_x = "x_to",
  end_y = "y_to",
  select_col_vec = c("from", "to", "distance")
)

Arguments

.data

A data frame containing columns for the x and y coordinates of start and end points.

start_x

Column name for the x-coordinate of the starting point.

start_y

Column name for the y-coordinate of the starting point.

end_x

Column name for the x-coordinate of the ending point.

end_y

Column name for the y-coordinate of the ending point.

select_col_vec

A character vector specifying the columns to be selected in the resulting data frame.

Value

A data frame with columns for the starting point, ending point, and calculated distances.

Examples

num_bins_x <- 4
shape_value <- 1.833091
hexbin_data_object <- extract_hexbin_centroids(nldr_df = s_curve_noise_umap,
num_bins = num_bins_x, shape_val = shape_value)
df_bin_centroids <- hexbin_data_object$hexdf_data
tr1_object <- triangulate_bin_centroids(df_bin_centroids, x, y)
tr_from_to_df <- generate_edge_info(triangular_object = tr1_object)
cal_2d_dist(tr_from_to_df, start_x = "x_from", start_y = "y_from",
end_x = "x_to", end_y = "y_to", select_col_vec = c("from", "to", "distance"))
#> # A tibble: 35 × 3
#>     from    to distance
#>    <dbl> <dbl>    <dbl>
#>  1     1     2     1.43
#>  2     1     3     1.54
#>  3     2     4     1.54
#>  4     3     6     1.54
#>  5     3     4     1.43
#>  6     4     7     1.54
#>  7     5     6     1.43
#>  8     5     8     2.54
#>  9     5    11     5.44
#> 10     5    13     7.71
#> # ℹ 25 more rows