Projecting geometries to lines and planes transforms the geometries to lie on the given line or plane by movement orthogonal to the line or plane. The geometry of the result of the projection is the same as the input. Not all geometries can be projected to lines and planes. Specifically, iso rectangles and iso cubes cannot do either and only 3 dimensional geometries can be projected to a plane. Circles and spheres are special in the sense that no ellipse and ellipsoid primitives exist. Because of this, projections will retain the radius and circularity of the primitives despite this not being geometrically sound. Projecting a 3D circle to a line will keep the orientation of the circle, while projecting it to a plane will adopt the orientation of the plane.

project(x, target)

x | A vector of geometries to project or map |
---|---|

target | A vector of lines or planes |

A vector of geometries of the same class as `x`

# Project a collection of segments to a line p <- point(sample(100, 8), sample(100, 8)) s <- segment(p[1:4], p[5:8]) project(s, line(3, 1, -6))#> <2D segments [4]> #> [1] [<x:-19, y:63>, <x:-18.9, y:62.7>] [<x:-6.8, y:26.4>, <x:-14.1, y:48.3>] #> [3] [<x:-3.9, y:17.7>, <x:-19, y:63>] [<x:-5.9, y:23.7>, <x:-10.6, y:37.8>]euclid_plot( project(s, line(3, 1, -6)), col = c("firebrick", "goldenrod", "steelblue", "forestgreen"), lwd = seq(20, 3, length.out = 4) )# Project a line to the x plane project(line(point(3, 7, -3), point(-2, 6, 0)), plane(point(0, 0, 0), vec(1, 0, 0)))#> <3D lines [1]> #> [1] <x:0, y:7, z:-3, dx:0, dy:-1, dz:3>