This function gives access to the underlying values defining the geometries
in a vector. As such they return the same information as calling
as.matrix()
on a geometry vector except the return value is kept as an
exact numeric and that you can extract from single elements if the
cardinality of the geometry exceeds 1.
Usage
def(x, ...)
# S3 method for euclid_geometry
def(x, name, which = NULL, ...)
# S3 method for euclid_affine_transformation
def(x, i, j, ...)
def(x, ...) <- value
# S3 method for euclid_geometry
def(x, name, which = NULL, ...) <- value
# S3 method for euclid_affine_transformation
def(x, i, j, ...) <- value
definition_names(x, ...)
Arguments
- x
A geometry vector
- ...
parameters to pass on
- name
Either a name or the index of the definition to extract, as matched to
definition_names(x)
- which
An integer vector giving the vertex from which the definition should be extracted, or
NULL
to extract all to extract all.- i, j
The row and column of the cell in the transformation to fetch.
- value
An
exact_numeric
vector or an object convertible to one
See also
Other Geometry methods:
euclid_geometry
,
subgeometries
Examples
# Get squared radius of circle
circ <- circle(point(4, 7), 25)
def(circ, "r2")
#> <exact numerics [1]>
#> [1] 25
# Set r2 to 10
def(circ, "r2") <- 10
circ
#> <2D circles [1]>
#> [1] <x:4, y:7, r2:10>
# Get all the x values from the source of segments
s <- segment(point(sample(10, 4), sample(10, 4)),
point(sample(10, 4), sample(10, 4)))
def(s, "x", 1L)
#> <exact numerics [4]>
#> [1] 7 6 2 4
# Get y for all subelements
def(s, "y")
#> <exact numerics [8]>
#> [1] 5 9 9 7 7 6 6 2
# Extract cell values from transformation matrices
m <- affine_rotate(c(pi/2, pi/3))
def(m, 1, 2)
#> <exact numerics [2]>
#> [1] -1.0000000 -0.8660254