Points are the fundamental unit in geometry, from which other geometric primitives can be constructed. Points support less than and greater than operations which are handled lexicographically. This means that point vectors can also be sorted and ranked. Subtracking a point from a point gives a vector. Adding and subtracting a vector to a point translates the point by the vector.

point(..., default_dim = 2)

is_point(x)

as_point(x)

## Arguments

... Various input. See the Constructor section. The dimensionality when constructing an empty vector A point vector or an object to convert to it

## Value

a euclid_point vector

## Constructors

2 dimensional points

• Providing two numeric vector will construct points with those x and y coordinate.

• Providing a vector will construct a point at the location the vector points to.

• Providing a weighted point vector will create a points at the same locations without weights.

3 dimensional points

• Providing three numeric vector will construct points with those x, y, and z coordinate.

• Providing a vector will construct a point at the location the vector points to.

• Providing a weighted point vector will create a points at the same locations without weights.

## Examples

num1 <- exact_numeric(runif(5))
num2 <- exact_numeric(runif(5))
num3 <- exact_numeric(runif(5))

# 2 dimensions
p <- point(num1, num2)
p
#> <2D points >
#>  <x:0.742, y:0.651> <x:0.549, y:0.529> <x:0.635, y:0.225> <x:0.137, y:0.983>
#>  <x:0.93, y:0.109>
plot(p) # 3 dimensions
point(num1, num2, num3)
#> <3D points >
#>  <x:0.742, y:0.651, z:0.0699> <x:0.549, y:0.529, z:0.778>
#>  <x:0.635, y:0.225, z:0.658>  <x:0.137, y:0.983, z:0.259>
#>  <x:0.93, y:0.109, z:0.918>
# Standard R vectors are automatically converted to exact_numeric vectors
point(runif(5), runif(5))
#> <2D points >
#>  <x:0.149, y:0.854>  <x:0.641, y:0.803>  <x:0.201, y:0.0239>
#>  <x:0.744, y:0.795>  <x:0.848, y:0.887>
# Convert points to vectors
as_vec(p)
#> <2D vectors >
#>  <x:0.742, y:0.651> <x:0.549, y:0.529> <x:0.635, y:0.225> <x:0.137, y:0.983>
#>  <x:0.93, y:0.109>
# Arithmetic
p + vec(3, 7)
#> <2D points >
#> [empty]
# Create vector by subtracting points
p[1:2] - p[3:4]
#> <2D vectors >
#> [empty]
# Sorting etc.
sort(p)
#> <2D points >
#>  <x:0.137, y:0.983> <x:0.549, y:0.529> <x:0.635, y:0.225> <x:0.742, y:0.651>
#>  <x:0.93, y:0.109> min(p)
#> <2D points >
#>  <x:0.137, y:0.983>cummax(p)
#> <2D points >
#>  <x:0.742, y:0.651> <x:0.549, y:0.529> <x:0.549, y:0.529> <x:0.137, y:0.983>
#>  <x:0.137, y:0.983>rank(p)
#> Error in if (xi > xj) 1L else -1L: argument is of length zerop[1:2] < p[3:4]
#> NULL