range() computes axis-aligned ranges for Coord1D, Coord2D,
Coord3D, Ellipse2D, Line2D, Plane3D, Point1D, and Segment2D
class objects.
Note that for Line2D and Plane3D objects the range may be -Inf to
Inf in one or more dimensions since lines and planes have infinite extent.
Usage
# S3 method for class 'Coord1D'
range(..., na.rm = FALSE)
# S3 method for class 'Coord2D'
range(..., na.rm = FALSE)
# S3 method for class 'Coord3D'
range(..., na.rm = FALSE)
# S3 method for class 'Segment2D'
range(..., na.rm = FALSE)
# S3 method for class 'Ellipse2D'
range(..., na.rm = FALSE)
# S3 method for class 'Point1D'
range(..., na.rm = FALSE)
# S3 method for class 'Line2D'
range(..., na.rm = FALSE)
# S3 method for class 'Plane3D'
range(..., na.rm = FALSE)Value
Either a Coord1D, Coord2D, or Coord3D object of length two. The first element will have the minimum x/y(/z) coordinates and the second element will have the maximum x/y(/z) coordinates of the axis-aligned ranges.
Examples
range(as_coord2d(rnorm(5), rnorm(5)))
#> <Coord2D[2]>
#> x y w
#> [1,] -1.710331 -0.5554843 1
#> [2,] 1.897827 1.1142686 1
range(as_coord3d(rnorm(5), rnorm(5), rnorm(5)))
#> <Coord3D[2]>
#> x y z w
#> [1,] -0.6294127 -1.660587 -1.3449404 1
#> [2,] 1.7627295 1.541007 -0.7489043 1
e <- as_ellipse2d(as_coord2d(c(0, 1), c(0, 1)), rx = c(1, 2), ry = c(0.5, 1))
range(e)
#> <Coord2D[2]>
#> x y w
#> [1,] -1 -0.5 1
#> [2,] 3 2.0 1
# A vertical line (x = 2) and a horizontal line (y = 3):
# x range covers only {2}, but y is Inf for the vertical line
l <- as_line2d(a = c(1, 0), b = c(0, 1), c = c(-2, -3))
range(l)
#> <Coord2D[2]>
#> x y w
#> [1,] -Inf -Inf 1
#> [2,] Inf Inf 1
# A plane perpendicular to the x-axis at x = 5
range(as_plane3d(a = 1, b = 0, c = 0, d = -5))
#> <Coord3D[2]>
#> x y z w
#> [1,] 5 -Inf -Inf 1
#> [2,] 5 Inf Inf 1
range(as_point1d(a = c(1, 1), b = c(-2, -5)))
#> <Coord1D[2]>
#> x w
#> [1,] 2 1
#> [2,] 5 1
s <- as_segment2d(as_coord2d(c(0, 1), c(0, 0)),
p2 = as_coord2d(c(1, 1), c(0, 1)))
range(s)
#> <Coord2D[2]>
#> x y w
#> [1,] 0 0 1
#> [2,] 1 1 1
