coordtri: Determine Third Coordinate of Triangle

Description Usage Arguments Details Value See Also Examples

View source: R/coordtri.R

Description

Determine the third coordinate of a triangle, given the other two coordinates and the distances to the third.

Usage

1
coordtri(cleft, cright, lleft, lright)

Arguments

cleft

A numeric vector of length 2, the x and y coordinates of the lower left point of the triangle (see details).

cright

A numeric vector of length 2, the x and y coordinates of the lower right point of the triangle (see details).

lleft

A numeric scalar, the length of the left side of the triangle, from cleft to the top (see details).

lright

A numeric scalar, the length of the right side of the triangle, from cright to the top (see details).

Details

The directions "left" and "right" refer to the triangle not necessarily in its current state, but rather after it has been rotated such that the bottom of the triangle is level (e.g., on the y=0 line), and the third coordinate that the function returns is "above" the bottom (e.g., y>0).

A warning message is given if a triangle can't be built from the inputs provided, and the returned value is c(NA, NA).

Value

A numeric vector of length 2, the x and y coordinates of the top point of the triangle.

See Also

coordplot, coordturn, coordmove, coordflip.

Examples

1
2
3
4
5
6
7
# define coordinates of base of triangle
AB <- rbind(A=c(-2, 4), B=c(2, -4))
# determine coordinates of top of triangle
# given base coordinates and side lengths
C <- coordtri(cleft=AB[1, ], cright=AB[2, ], lleft=12, lright=10)
# plot results
coordplot(rbind(C, AB))

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.