Skip to contents

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.

Usage

project(x, target, ...)

# S3 method for euclid_geometry
project(x, target, ...)

Arguments

x

A vector of geometries to project or map

target

A vector of lines or planes

...

Arguments passed on to methods

Value

A vector of geometries of the same class as x

See also

Other Projections: map_to(), normal()

Examples

# 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:-20.6, y:67.8>, <x:-16.2, y:54.6>]
#> [2] [<x:2.9, y:-2.7>, <x:-4.7, y:20.1>]   
#> [3] [<x:1.2, y:2.4>, <x:-18.3, y:60.9>]   
#> [4] [<x:-4.8, y:20.4>, <x:-2.6, y:13.8>]  

plot(line(3, 1, -6), xlim = c(-50, 100), ylim = c(-50, 100))
euclid_plot(s, col = c("firebrick", "goldenrod", "steelblue", "forestgreen"))
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>