11/**
2- * The purpose of this tool is to allow JRubyArt users to use an alternative
2+ * The purpose of this tool is to allow JRubyArt users to use an alternative
33 * to processing.org map, lerp and norm methods in their sketches
4- * Copyright (C) 2015 Martin Prout. This tool is free software; you can
5- * redistribute it and/or modify it under the terms of the GNU Lesser General
4+ * Copyright (C) 2015 Martin Prout. This tool is free software; you can
5+ * redistribute it and/or modify it under the terms of the GNU Lesser General
66 * Public License as published by the Free Software Foundation; either version
77 * 2.1 of the License, or (at your option) any later version.
8- *
8+ *
99 * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
1010 */
1111package monkstone ;
@@ -29,7 +29,7 @@ public class MathTool extends RubyObject {
2929
3030 /**
3131 *
32- * @param runtime
32+ * @param runtime Ruby
3333 */
3434 public static void createMathTool (Ruby runtime ) {
3535 RubyModule processing = runtime .defineModule ("Processing" );
@@ -39,10 +39,10 @@ public static void createMathTool(Ruby runtime) {
3939
4040 /**
4141 *
42- * @param context JRuby runtime
43- * @param recv self
42+ * @param context ThreadContext
43+ * @param recv IRubyObject
4444 * @param args array of RubyRange (must be be numeric)
45- * @return RubyFloat
45+ * @return mapped value RubyFloat
4646 */
4747 @ JRubyMethod (name = "map1d" , rest = true , module = true )
4848 public static IRubyObject mapOneD (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
@@ -58,10 +58,10 @@ public static IRubyObject mapOneD(ThreadContext context, IRubyObject recv, IRuby
5858
5959 /**
6060 *
61- * @param context JRuby runtime
62- * @param recv self
61+ * @param context ThreadContext
62+ * @param recv IRubyObject
6363 * @param args array of RubyRange (must be be numeric)
64- * @return RubyFloat
64+ * @return mapped value RubyFloat
6565 */
6666 @ JRubyMethod (name = "constrained_map" , rest = true , module = true )
6767 public static IRubyObject constrainedMap (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
@@ -82,13 +82,13 @@ public static IRubyObject constrainedMap(ThreadContext context, IRubyObject recv
8282 }
8383 return mapMt (context , value , first1 , last1 , first2 , last2 );
8484 }
85-
85+
8686 /**
8787 *
88- * @param context JRuby runtime
89- * @param recv self
88+ * @param context ThreadContext
89+ * @param recv self IRubyObject
9090 * @param args floats as in processing map function
91- * @return RubyFloat
91+ * @return mapped value RubyFloat
9292 */
9393 @ JRubyMethod (name = "p5map" , rest = true , module = true )
9494 public static IRubyObject mapProcessing (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
@@ -98,15 +98,15 @@ public static IRubyObject mapProcessing(ThreadContext context, IRubyObject recv,
9898 double last1 = (Double ) args [2 ].toJava (Double .class );
9999 double last2 = (Double ) args [4 ].toJava (Double .class );
100100 return mapMt (context , value , first1 , last1 , first2 , last2 );
101- }
102-
101+ }
102+
103103
104104 /**
105105 * A more correct version than processing.org version
106- * @param context
107- * @param recv
106+ * @param context ThreadContext
107+ * @param recv self IRubyObject
108108 * @param args args[2] should be between 0 and 1.0 if not returns start or stop
109- * @return
109+ * @return lerped value RubyFloat
110110 */
111111 @ JRubyMethod (name = "lerp" , rest = true , module = true )
112112 public static IRubyObject lerpP (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
@@ -116,33 +116,33 @@ public static IRubyObject lerpP(ThreadContext context, IRubyObject recv, IRubyOb
116116 if (amount <= 0 ) return args [0 ];
117117 if (amount >= 1.0 ) return args [1 ];
118118 return context .getRuntime ().newFloat ((1 - amount ) * start + (stop * amount ));
119- }
119+ }
120+
120121
121-
122122 /**
123123 * Identical to p5map(value, low, high, 0, 1).
124- * Numbers outside of the range are not clamped to 0 and 1,
125- * because out-of-range values are often intentional and useful.
126- * @param context
127- * @param recv
128- * @param args
129- * @return
124+ * Numbers outside of the range are not clamped to 0 and 1,
125+ * because out-of-range values are often intentional and useful.
126+ * @param context ThreadContext
127+ * @param recv IRubyObject
128+ * @param args array of args must be be numeric
129+ * @return mapped value RubyFloat
130130 */
131131 @ JRubyMethod (name = "norm" , rest = true , module = true )
132- public static IRubyObject normP (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
132+ public static IRubyObject normP (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
133133 double value = (Double ) args [0 ].toJava (Double .class );
134134 double start = (Double ) args [1 ].toJava (Double .class );
135- double stop = (Double ) args [2 ].toJava (Double .class );
135+ double stop = (Double ) args [2 ].toJava (Double .class );
136136 return mapMt (context , value , start , stop , 0 , 1.0 );
137137 }
138-
138+
139139 /**
140140 * Identical to p5map(value, low, high, 0, 1) but 'clamped'.
141- * Numbers outside of the range are clamped to 0 and 1,
142- * @param context
143- * @param recv
144- * @param args
145- * @return
141+ * Numbers outside of the range are clamped to 0 and 1,
142+ * @param context ThreadContext
143+ * @param recv IRubyObject
144+ * @param args array of args must be be numeric
145+ * @return mapped value RubyFloat
146146 */
147147 @ JRubyMethod (name = "norm_strict" , rest = true , module = true )
148148 public static IRubyObject norm_strict (ThreadContext context , IRubyObject recv , IRubyObject [] args ) {
@@ -157,18 +157,18 @@ public static IRubyObject norm_strict(ThreadContext context, IRubyObject recv, I
157157 } else {
158158 return mapMt (context , value , start , stop , 0 , 1.0 );
159159 }
160- }
161-
162- static final RubyFloat mapMt (ThreadContext context , double value , double first1 , double last1 , double first2 , double last2 ) {
160+ }
161+
162+ static final RubyFloat mapMt (ThreadContext context , double value , double first1 , double last1 , double first2 , double last2 ) {
163163 double result = first2 + (last2 - first2 ) * ((value - first1 ) / (last1 - first1 ));
164164 return context .getRuntime ().newFloat (result );
165165 }
166-
166+
167167 /**
168168 * Provides processing constrain method as a ruby module method
169- * @param context
170- * @param recv
171- * @param args
169+ * @param context ThreadContext
170+ * @param recv IRubyObject
171+ * @param args array of args must be be numeric
172172 * @return original or limit values
173173 */
174174 @ JRubyMethod (name = "constrain" , rest = true , module = true )
@@ -185,12 +185,10 @@ public static IRubyObject constrainValue(ThreadContext context, IRubyObject recv
185185 }
186186 }
187187
188-
189-
190188 /**
191189 *
192- * @param runtime
193- * @param metaClass
190+ * @param runtime Ruby
191+ * @param metaClass RubyClass
194192 */
195193 public MathTool (Ruby runtime , RubyClass metaClass ) {
196194 super (runtime , metaClass );
0 commit comments