ropensci / stplanr

Sustainable transport planning with R
https://docs.ropensci.org/stplanr
Other
416 stars 66 forks source link

add funtions to cal angle to prevent sideroads getting values of main road #524

Closed wangzhao0217 closed 10 months ago

wangzhao0217 commented 10 months ago
wangzhao0217 commented 10 months ago

Hi @Robinlovelace Currently, I couldn't find a more efficient method to prevent sideroads from getting values from the main road, except to use the angle calculation method. I did the following update on file rnet_join.R

calculate_angle <- function(vector1, vector2) { dot_product <- sum(vector1 vector2) magnitude_product <- sqrt(sum(vector1^2)) sqrt(sum(vector2^2)) cos_angle <- dot_product / magnitude_product angle <- acos(cos_angle) * (180 / pi) return(angle) }


However, it is still not working, will keep fixing it.
Robinlovelace commented 10 months ago

Thanks Zhao, will take a look.

wangzhao0217 commented 10 months ago

will make new pr

Robinlovelace commented 10 months ago

Sounds good, looking forward to reviewing it and seeing the results.