In processing (processing.org programming language) many people implement fast sin/cos math using lookup tables, with either limited precision but accurate degree input. Or with limited precision (say 0.25 degree) and limited accuracy, with radian input (and typically table is stored as array of floats). Is there any point in trying to wrap a java version into jruby (not for everyone, but just local to say ruby-processing) for graphical work. On a related note I have written a 2D and 3D vector library https://github.com/jashkenas/ruby-processing/blob/... in purely ruby for use with ruby-processing, would I gain anything by re-implementing it in java and writing a jruby wrapper, like yokolets Fraction, that wraps Apache Commons Math API to provide a ruby version. http://yokolet.blogspot.co.uk/2011/05/extending-jruby.html.
on 2014-04-14 07:54
on 2014-04-26 18:17
OK no-one replied, I did more research and decided to put my foot in the water. Here is progress so far at implementing my 2D ruby vector library in JRuby (java) http://learning-ruby-processing.blogspot.co.uk/201.... I did this because it looks to me that the biggest slowdown is calling java from ruby and vice-versa. I have yet to test performance, but it was an interesting exercise.
on 2014-04-27 16:32
Hi Martin, Why don't you use MDMatrix class from MDArray? I haven't replied before because I don't really understand why you need to do all those complex calls and don't just import java methods to jruby. Cheers, Rodrigo Em 26/04/2014 13:18, "Martin Prout" <firstname.lastname@example.org> escreveu:
on 2014-04-27 20:19
I was only going on this https://twitter.com/headius/status/349225854842306560 from Charlie. In my experiments it is almost pointless trying to do speed ups in java as these will not come through to ruby-processing performance. The point of ruby-processing is to be able to write regular ruby code. If you only wanted performance you would stick to vanilla processing. Performance is not bad, even with my Vecmath libary written in ruby, I reasoned that if it were pre-compiled it might work even better. From the users point of view my library will appear as though it were written in ruby.
on 2014-04-28 08:36
I have now made my experimental JRuby extension available at github https://github.com/ruby-processing/RVecMath I'm hesitant to offer it as possible template because it is my first attempt, and there is an absolute dearth of examples (apart from yokolets excellent example without which I would have never started). However judging my spec test it at least all seems to work. I have expanded yokolets example to include a static method (other than new) methods which take a variable number of arguments etc. Many of these additional features were partly achieved by trial and error. If I was confident I was right I would write a guide.
on 2014-05-04 22:29
I have now added to the functionality of my Vecmath library https://github.com/ruby-processing/RVecMath which will very likely get incorporated into ruby-processing. Perhaps the most useful feature is that of the ArcBall functionality, which can be implemented on the ruby side with a one liner (by making use of java reflection in processing). Less interesting is the degree input and degree precision sine / cosine lookup tables that manage at best 30-40% performance gain over regular Math.sin and Math.cos. In practice this (ie in a ruby-processing sketch) performance gain may be even more marginal.