VPPS-SS14-W04-1-TimsStruppis






# Definieren eine Funktion die Grad in Radianten umwandelt
degToRad <- function(alpha) {
    alpha * pi/180
}

# Definieren Funktion die uns An- und Gegenkathete ausgibt
hypoAlphaToGegenAn <- function(c, alpha) {
    a <- sin(degToRad(alpha)) * c
    b <- cos(degToRad(alpha)) * c
    result <- data.frame(x = round(a, 2), y = round(b, 2))
    return(result)
}

# Ueberpruefen der Funktionen

hypoAlphaToGegenAn(10, 90)
##    x y
## 1 10 0

One thought on “VPPS-SS14-W04-1-TimsStruppis

  1. Tim Appelhans

    Nice to see that the coversion from degrees to radians was moved to an additional function. Yet, in order to help the user, why not include the ‘degToRad()’ in ‘hypoAlphaToGegenAn()’ so that the user does not have to worry about supplying it in the function call.

    It is much more likely that users will collect data in degrees rather than radians, so assuming that what gets passed to the function will most likely be in degrees seems a save bet.

Leave a Reply