A normal is a direction perpendicular to a geometry. Since normals doesn't have any magnitude they are returned as directions rather than vectors. Normals are not given for all geometries. In 2 dimensions they are defined for line-like geometries (directions, vectors, lines, rays, and segments), while in 3 dimensions they are given for plane-like geometries (circles, triangles, and planes).

normal(x, y = NULL)

Arguments

x, y

Geometry vectors. If y is given both x and y must be convertible to vectors and be in 3D

Value

A vector of directions with the same dimensionality as the input

Examples

# Get normals to a vector of directions d <- direction(sample(10, 5), sample(10,5)) normal(d)
#> <2D directions [5]> #> [1] <dx:-4, dy:3> <dx:-3, dy:1> <dx:-1, dy:8> <dx:-2, dy:5> <dx:-8, dy:9>
# Get the normal of a triangle t <- triangle(point(4, 7, 1), point(9, 2, 1), point(1, 6, 8)) normal(t)
#> <3D directions [1]> #> [1] <dx:-35, dy:-35, dz:-20>
# equivalent to the normal of the supporting plane normal(t) == normal(as_plane(t))
#> [1] TRUE
# Get direction orthogonal to two vectors normal(vec(5, 2, -7), vec(-1, 4, 9))
#> <3D directions [1]> #> [1] <dx:46, dy:-38, dz:22>