Calculate distance between 2 points
Arguments
- x
a point, line, segment, or circle object
- y
a point, line, or circle object
- ...
<
dynamic-dots
> Not used
Examples
# Distance between two objects
p1 <- ob_point(0, 0)
p2 <- ob_point(3, 4)
distance(p1, p2)
#> [1] 5
# Distance between the endpoints of a segment
s1 <- ob_segment(p1, p2)
distance(s1)
#> [1] 5
# Distance between a point and a line
l1 <- ob_line(slope = 0, intercept = 1)
distance(p1, l1)
#> [1] 1
# Shortest distance between the edges of 2 circles
c1 <- ob_circle(p1, radius = 1)
c2 <- ob_circle(p2, radius = 2)
distance(c1, c2)
#> [1] 2