The base vector type for geometries in euclid is the `euclid_geometry`

class.
While this is a virtual class (you cannot construct it, only its subclasses),
many of the common vector operations are defined here. Further it is possible
to check whether a vector is a geometry of any type using `is_geometry()`

.
While most geometries are atomic, a few are defined by multiples of the same
geometry, e.g. segments and triangles which are defined by 2 and 3 points
respectively. The cardinality of each geometry in a vector can be queried
with `cardinality()`

. The matrix conversion will place each sub-geometry of
a geometry on a new row, meaning that the final number of rows in a matrix
constructed from `x`

is not `length(x)`

but `sum(cardinality(x))`

.

```
is_geometry(x)
geometry_type(x)
cardinality(x)
definition_names(x)
```

- x
An

`euclid_geometry`

object

Geometry vectors in euclid are made to behave as closely as possible to what you expect from normal R vectors. However, they are implemented as external pointers to the exact C representation meaning that they cannot be restored across sessions or saved to RData/RDS files. Despite being external pointers they mimick R's copy-on-modify semantics so you should not worry about side effects when changing a geometry vector.

The following is a list of standard R methods defined for geometry vectors:

`as.matrix()`

- converts the geometry to a standard R matrix of numerics`as.character()`

- provides a textual representation of the geometry`format()`

- as above`as.list()`

- splits the vector into single elements in a list`str()`

- provides a condensed view of the vector`length()`

- gives the number of geometries in the vector`rep()`

- replicates elements in the vector`seq()`

- interpolate between two geometries of the same type and dimensionality`dim()`

- gives the dimensionality of the geometry (2 or 3)[

`[`

] and [`[[`

] - extract elements from the vector[

`[<-`

] and [`[[<-`

] - assigns elements into the vector. Since`NA`

values are not supported it is not possible to assign past the length of the vector`$`

and`$<-`

- will throw an error since geometry vectors are unnamed`c()`

- combine multiple geometries of the same type`unique()`

- returns the unique elements of the vector keeping the order`duplicated()`

- gives whether an element has been seen before in the vector`anyDuplicated()`

- Tells if any element in the vector is a duplicate`transform()`

- Transform geometries in the vector according to an affine_transformation

Do note that since geometries with exact representation is not easily
hashable, the implementation of `unique()`

and `duplicated()`

is not very
efficient (except for points since they can be sorted).

```
p <- point(sample(10, 4), sample(10, 4))
p
#> <2D points [4]>
#> [1] <x:5, y:9> <x:2, y:6> <x:7, y:7> <x:3, y:2>
p[2]
#> <2D points [1]>
#> [1] <x:2, y:6>
p[3] <- point(14, 20)
p
#> <2D points [4]>
#> [1] <x:5, y:9> <x:2, y:6> <x:14, y:20> <x:3, y:2>
p2 <- c(p, p)
p2
#> <2D points [8]>
#> [1] <x:5, y:9> <x:2, y:6> <x:14, y:20> <x:3, y:2> <x:5, y:9>
#> [6] <x:2, y:6> <x:14, y:20> <x:3, y:2>
unique(p2)
#> <2D points [4]>
#> [1] <x:5, y:9> <x:2, y:6> <x:14, y:20> <x:3, y:2>
sort(p)
#> <2D points [4]>
#> [1] <x:2, y:6> <x:3, y:2> <x:5, y:9> <x:14, y:20>
rep(p, each = 2)
#> <2D points [8]>
#> [1] <x:5, y:9> <x:5, y:9> <x:2, y:6> <x:2, y:6> <x:14, y:20>
#> [6] <x:14, y:20> <x:3, y:2> <x:3, y:2>
as.list(p)
#> [[1]]
#> <2D points [1]>
#> [1] <x:5, y:9>
#>
#> [[2]]
#> <2D points [1]>
#> [1] <x:2, y:6>
#>
#> [[3]]
#> <2D points [1]>
#> [1] <x:14, y:20>
#>
#> [[4]]
#> <2D points [1]>
#> [1] <x:3, y:2>
#>
transform(p, affine_rotate(pi/3))
#> <2D points [4]>
#> [1] <x:-5.29, y:8.83> <x:-4.2, y:4.73> <x:-10.3, y:22.1> <x:-0.232, y:3.6>
```