VPPS-SS14-W04-1-Supernasen




# calculates the length of leg a and b of a right triangle when c and alpha
# is given
calculateTriangle <- function(alpha, c) {
    alphaRad <- alpha * pi/180
    a <- sin(alphaRad) * c
    b <- cos(alphaRad) * c
    result <- data.frame(x = round(a, 2), y = round(b, 2))
    return(result)
}

# example of function usage
calculateTriangle(45, 60)
##       x     y
## 1 42.43 42.43

3 thoughts on “VPPS-SS14-W04-1-Supernasen

    1. Supernasen Post author

      Thanks for your feedback, Tim. This function might be the better solution, anyway. Are you happy with the style of the function, now?

Leave a Reply