Skip to contents

Triangles are sets of three vertices in either 2 or three dimensions. In three dimensions the order of the vertices determines the orientation of the triangle with vertices being in counter-clockwise order from the facing side. If the 3 vertices are colinear the triangle is considered to be degenerate

Usage

triangle(..., default_dim = 2)

is_triangle(x)

as_triangle(x)

Arguments

...

Various input. See the Constructor section.

default_dim

The dimensionality when constructing an empty vector

x

A vector of triangles or an object to convert to it

Value

An euclid_triangle vector

Constructors

2 and 3 dimensional triangles

  • Providing three points will construct triangles in the order the points are given.

See also

Other Geometries: circle(), direction(), iso_cube(), iso_rect(), line(), plane(), point(), ray(), segment(), sphere(), tetrahedron(), vec(), weighted_point()

Other Surfaces: circle(), iso_rect(), plane()

Examples

# Construction
p <- point(sample(6), sample(6))
t <- triangle(p[1:2], p[3:4], p[5:6])
t
#> <2D triangles [2]>
#> [1] [<x:1, y:4>, <x:3, y:2>, <x:5, y:3>] [<x:6, y:1>, <x:4, y:6>, <x:2, y:5>]
plot(t)


# 3D triangles can be converted to planes
p <- point(sample(6), sample(6), sample(6))
t <- triangle(p[1:2], p[3:4], p[5:6])
as_plane(t)
#> <3D euclid_planes [2]>
#> [1] <a:-5, b:-1, c:-7, d:50> <a:-7, b:-12, c:1, d:39>