Geometries located in space (all except directions and vectors), have one or more points supporting it. Those can be extracted and modifed with vert(). For geometries with a cardinality above one there's a choice of which support point to extract/modify or all. Geometries consisting of more than one vertex (segments, triangles, and tetrahedrons) also have associated edges that can be extracted (but not modified) with edge(). edge_count() provides the number of edges in each element in the geometry vector. The length of the output of edge(x) is sum(edge_count(x)).

## Usage

vert(x, which = NULL, ...)

vert(x, which = NULL, ...) <- value

edge(x, which = NULL, ...)

edge_count(x)

## Arguments

x

A vector of geometries

which

An integer vector giving the vertex/edge to extract, or NULL to extract all.

...

arguments passed on to methods

value

An euclid_point vector of the same dimensionality as x

## Value

A euclid_point vector for vert() or a euclid_segment vector for edge() matching the dimensionality of x

## Vertex definition

For geometries that are defined exclusively by points the definition of the output is straight forward, e.g. for triangles vert() will extract one or all of the corners depending on the value of which. For the other geometries the output is defined according to the below:

• circles and spheres: The vertex is the center

• rays: The vertex is the source

• lines and planes: The vertex is an arbitrary point on the geometry

Other Geometry methods: def(), euclid_geometry

## Examples

# Get the source vertex in a segment
s <- segment(point(3, 6), point(1, -7))
vert(s, 1)
#> <2D points [1]>
#> [1] <x:3, y:6>

# And the target
vert(s, 2)
#> <2D points [1]>
#> [1] <x:1, y:-7>

# Not providing an index extracts them all
vert(s)
#> <2D points [2]>
#> [1] <x:3, y:6>  <x:1, y:-7>

# Set the source of a segment
vert(s, 1) <- point(0, 0)
s
#> <2D segments [1]>
#> [1] [<x:0, y:0>, <x:1, y:-7>]

# Get a point on a line
l <- line(4, 7, -1)
vert(l)
#> <2D points [1]>
#> [1] <x:1, y:-0.429>

# Setting the vertex of a line moves it so it runs through it
point(1, 2) %is_on% l
#> [1] FALSE
vert(l) <- point(1, 2)
point(1, 2) %is_on% l
#> [1] TRUE

# Get one of the sides from a triangle
t <- triangle(point(1, 2), point(6, 3), point(3, 1))
edge(t, 2)
#> <2D segments [1]>
#> [1] [<x:6, y:3>, <x:3, y:1>]

# or all
edge(t)
#> <2D segments [3]>
#> [1] [<x:1, y:2>, <x:6, y:3>] [<x:6, y:3>, <x:3, y:1>] [<x:3, y:1>, <x:1, y:2>]