Skip to contents

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).

Usage

normal(x, ...)

# S3 method for euclid_geometry
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

...

Arguments passed on to methods

Value

A vector of directions with the same dimensionality as the input

See also

Other Projections: map_to(), project()

Examples

# Get normals to a vector of directions
d <- direction(sample(10, 5), sample(10,5))
normal(d)
#> <2D directions [5]>
#> [1] <dx:-3, dy:9>  <dx:-4, dy:1>  <dx:-5, dy:6>  <dx:-10, dy:2> <dx:-7, dy:7> 

# 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>