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:5, y:6>, <x:2, y:4>, <x:3, y:5>] [<x:1, y:1>, <x:6, y:2>, <x:4, y:3>]
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:3, c:4, d:-40> <a:1, b:0, c:1, d:-7>