#1 13. Februar 2008 Hey, Ruby scheint keine Winkelsätze (konkret brauch ich arccos) zu kennen. Jemand ne Idee woher ich nen plugin/modul oder sowas dafür herbekommen könnte? grüße My-Doom + Multi-Zitat Zitieren
#2 13. Februar 2008 AW: Winkelsätze in ruby? Code: [B]Calculating More Trigonometric Functions[/B] sin_val = Math.sin(angle) cos_val = Math.cos(angle) tan_val = Math.tan(angle) # AFAIK Ruby's Math module doesn't provide acos/asin # While we're at it, let's also define missing hyperbolic functions module Math def Math.asin(x) atan2(x, sqrt(1 - x**2)) end def Math.acos(x) atan2(sqrt(1 - x**2), x) end def Math.atan(x) atan2(x, 1) end def Math.sinh(x) (exp(x) - exp(-x)) / 2 end def Math.cosh(x) (exp(x) + exp(-x)) / 2 end def Math.tanh(x) sinh(x) / cosh(x) end end # The support for Complex numbers is not built-in y = Math.acos(3.7) #=> in `sqrt': square root for negative number (ArgumentError) # There is an implementation of Complex numbers in 'complex.rb' in current # Ruby distro, but it doesn't support atan2 with complex args, so it doesn't # solve this problem. Das sollte evtl deine Frage beantworten. Also fehlende Funktionen selber schreiben/definieren! Link: http://pleac.sourceforge.net/pleac_ruby/numbers.html greez + Multi-Zitat Zitieren