// java/processing 9 float arguments void camera( float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ){...} // default values camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);
Since we can now use ruby-2.0 syntax (with jruby-9.0.0.0) there is scope for improvement, by using keyword arguments and Vector object (need not be Vec3D a Struct would do):-
# ruby 3 named parameters (order would be unimportant) def camera_vec( eye: Vec3D.new(width / 2.0, height / 2.0, (height / 2.0) / tan(PI * 30.0 / 180.0)), center: Vec3D.new(width / 2.0, height / 2.0, 0), up: Vec3D.new(0, 1.0, 0)) camera(eye.x, eye.y, eye.z, center.x, center.y, center.z, up.x, up.y, up.z) end
No comments:
Post a Comment