Skip to contents

Geometry types

The core of euclid is a range of new primitive vector types modelling different types of geometries. When applicable, the types comes in both a 2 and 3 dimensional version. The vector types behaves much like regular R vectors in terms of subsetting, equality, etc. When it makes sense they also respond to arithmetic and sorting operations.

Other data types

In addition to vectors of geometries euclid also provides a few other primitive types to support geometric operations. As with the vectors of geometries, these data types behaves much like normal R vectors.

Data access

Geometries are based on parameters and sometimes supporting points. These can be extracted in various ways.

def() `def<-`() definition_names()
Access the exact values that defines the geometries
vert() `vert<-`() edge() edge_count()
Extract vertices and edges from geometries

Predicates

At the core of a lot of geometric algorithms lies predicates on geometries. This is also a place where floating points often leads to failures since e.g. a point constructed to lie on a plane may end up slightly off the plane due to rounding and imprecisions. The euclid predicates are exact, however, as long as the geometries have been constructed within the framework.

is_degenerate()
Check if a geometry is degenerate
has_on() `%is_on%` has_inside() `%is_inside%` has_outside() `%is_outside%` has_on_positive_side() `%is_on_positive_side%` has_on_negative_side() `%is_on_negative_side%`
Query location of points relative to geometry
is_constant_in() has_constant_x() has_constant_y() has_constant_z()
Check geometries for axis alignment
has_intersection() `%is_intersecting%`
Query whether geometries intersect
parallel()
Check geometries for parallelity
collinear() coplanar()
Check geometries for whether they are collinear or coplanar
in_order() in_order_along()
Check whether points are collinear and ordered along the line
turns_left() turns_right() turn_along()
Query the side of the turn constructed by three consecutive points

Transformations

Geometries can be transformed by affine transformation matrices using the transform() method. In addition, other types of transformations are available, such as projections to lines and planes.

project()
Project geometries to lines and planes
map_to()
Map 3D geometries to 2D based on plane
normal()
Get the normal of a geometry

Intersections

Intersection of geometries is at the heart of many algorithms and is complicated by their unpredictable output type. Further, not all intersections can be represented exactly.

Boolean operations

While euclid only provides intersection methods for its data types it provides generics that can be used by extension packages to add onto it. See e.g. the polyclid package that provides the full set of 2D boolean set operations for polygons and polylines.

union() difference() symmetric_difference() complement()
Boolean operations on geometries

Measures

Measures on geometries such as area, length, and volume, cannot always be given in exact numbers due to reliance on square roots, pi, and other inexact operations. Because of this they are here provided as approximate measures in the sense that they are subjected to the imprecisions of floating point arithmetic. Further, pairwise measures such as distance is given as well.

approx_length() approx_area() approx_volume() approx_radius()
Approximate geometry measures
distance_squared() approx_distance_matrix()
Calculate distances between geometries
approx_angle()
Calculate angle between geometries

Locations

Single geometries or collections of them can define specific locations in space, often points, but also lines and planes. euclid provides a range of functionality for calculating these.

centroid()
Calculate the centroid of a geometry or a set of points
circumcenter()
Calculate circumcenter of triangles, tetrahedrons, or sets of points
barycenter()
Calculate barycenter of a set of weighted points
bisector()
Calculate the bisector of two geometries
equidistant_line()
Construct the equidistant line of 2 or three points
radical()
Calculate radical point, line, or plane of two circles or spheres

Plotting

Geometry and drawing goes hand in hand. Euclid provides direct support for both base and grid graphics when it comes to 2D geometries. 3D geometries is not supported at the moment, but will be in the future.

euclid_plot() euclid_grob() plot(<euclid_geometry>)
Plotting functions for geometries