[R] object class for triangles
Ember Kata
ember.kata at gmail.com
Sun May 13 12:11:24 CEST 2007
My task is to create an object class for triangles. I have made a function:
triangle<- function(a,b,gamma) {
c <- sqrt (a^2+b^2-2*a*b*cos(gamma/180*pi))
beta <- (acos((a^2+c^2-b^2)/(2*a*c)))/pi*180
alfa <- 180-(beta+gamma)
T <- (a*b*sin(gamma/180*pi))/2
K <- a+b+c
cat ('side of triangle: ',a,b,c,'\n',
'degree of triangle: ',alfa,beta,gamma,'\n',
'perimeter: ',K,'area:', T)}
But this is only a simple function without object or class. Can you help me,
how I can make an object class for triangles from this?
Thanks,
Ember Kata
--
View this message in context: http://www.nabble.com/object-class-for-triangles-tf3734550.html#a10453594
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list