righttri: Right triangle calculations

righttriR Documentation

Right triangle calculations

Description

This function computes the missing length (must have at least 2 sides) and the interior angles (degrees) of a right triangle.

Usage

righttri(a = NULL, b = NULL, c = NULL)

Arguments

a

numeric vector that contains the known side a, if known

b

numeric vector that contains the known side b, if known

c

numeric vector that contains the known side c (hypotenuse), if known

Details

Side a is the side adjacent to angle B and opposite angle A. Side b is the side adjacent to angle A and opposite angle B. Side c (hypotenuse) is opposite the right angle (angle C).

This function makes the following calculations:

  1. the length of the missing side using the Pythagorean theorem,

  2. the area of the right triangle,

  3. the altitude of the right triangle,

  4. the angle associated with the side named a (degrees),

  5. the angle associated with the side named b (degrees), and

  6. the angle associated with the side named c (degrees).

Value

list of known sides a, b, and c & the interior angles A, B, and C (right angle), in degrees, if and only if the given sides create a right triangle.

Author(s)

Irucka Embry

Source

  1. r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See https://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.

  2. r - switch() statement usage - Stack Overflow answered by Tommy on Oct 19 2011 and edited by Tommy on Mar 6 2012. See https://stackoverflow.com/questions/7825501/switch-statement-usage.

  3. Using Switch Statement in R - Stack Overflow answered by Gavin Simpson on Jul 25 2013. See https://stackoverflow.com/questions/17847034/using-switch-statement-in-r.

  4. r - How to not run an example using roxygen2? - Stack Overflow answered and edited by samkart on Jul 9 2017. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/12038160/how-to-not-run-an-example-using-roxygen2.

  5. devtools - Issues in R package after CRAN asked to replace dontrun by donttest - Stack Overflow answered by Hong Ooi on Sep 1 2020. (Also see the additional comments in response to the answer.) See https://stackoverflow.com/questions/63693563/issues-in-r-package-after-cran-asked-to-replace-dontrun-by-donttest.

References

  1. r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See https://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.

  2. Masoud Olia, Ph.D., P.E. and Contributing Authors, Barron's FE (Fundamentals of Engineering Exam), 3rd Edition, Hauppauge, New York: Barron's Educational Series, Inc., 2015, page 44-45.

  3. Wikimedia Foundation, Inc. Wikipedia, 28 December 2015, "Pythagorean theorem", https://en.wikipedia.org/wiki/Pythagorean_theorem.

  4. Wikimedia Foundation, Inc. Wikipedia, 26 November 2015, "Radian", https://en.wikipedia.org/wiki/Radian.

  5. Wikimedia Foundation, Inc. Wikipedia, 9 December 2015, "Right triangle", https://en.wikipedia.org/wiki/Right_triangle.

Examples


library(iemisc)

righttri(a = 3, b = 4, c = 5)





# See Source 4 and Source 5

library(iemisc)

try(righttri(0, 2)) # a = 0, b = 2

try(righttri(1, 2)) # a = 1, b = 2

try(righttri(a = 5, c = 10))

try(righttri(a = 3, c = 10))








iemisc documentation built on Sept. 25, 2023, 5:09 p.m.