distance | R Documentation |
Calculate distance between 2 points
distance(x, y, ...)
x |
an ob_point, ob_line, ob_segment, or object with a center point (e.g., ob_circle, ob_rectangle, ob_ellipse) |
y |
an ob_point, ob_line, ob_segment, or object with a center point (e.g., ob_circle, ob_rectangle, ob_ellipse) |
... |
< |
numeric
# Distance between two objects
p1 <- ob_point(0, 0)
p2 <- ob_point(3, 4)
distance(p1, p2)
# Distance between the endpoints of a segment
s1 <- ob_segment(p1, p2)
distance(s1)
# Distance between a point and a line
l1 <- ob_line(slope = 0, intercept = 1)
distance(p1, l1)
# Shortest distance between the edges of 2 circles
c1 <- ob_circle(p1, radius = 1)
c2 <- ob_circle(p2, radius = 2)
distance(c1, c2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.