mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 13:21:07 +01:00
random functions in processingapplet, notes in todo
This commit is contained in:
@@ -509,24 +509,11 @@ public class ProcessingApplet extends Applet
|
||||
|
||||
// math stuff for convenience
|
||||
|
||||
|
||||
public final float sin(float angle) {
|
||||
return (float)Math.sin(angle);
|
||||
}
|
||||
|
||||
public final float cos(float angle) {
|
||||
return (float)Math.cos(angle);
|
||||
public final float abs(float n) {
|
||||
return (n < 0) ? -n : n;
|
||||
}
|
||||
|
||||
public final float tan(float angle) {
|
||||
return (float)Math.tan(angle);
|
||||
}
|
||||
|
||||
public final float atan2(float a, float b) {
|
||||
return (float)Math.atan2(a, b);
|
||||
}
|
||||
|
||||
|
||||
public final float sq(float a) {
|
||||
return a*a;
|
||||
}
|
||||
@@ -539,10 +526,6 @@ public class ProcessingApplet extends Applet
|
||||
return (float)Math.pow(a, b);
|
||||
}
|
||||
|
||||
public final float abs(float n) {
|
||||
return (n < 0) ? -n : n;
|
||||
}
|
||||
|
||||
|
||||
public final float max(float a, float b) {
|
||||
return Math.max(a, b);
|
||||
@@ -561,8 +544,48 @@ public class ProcessingApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public final float random() {
|
||||
return (float)Math.random();
|
||||
|
||||
public final float sin(float angle) {
|
||||
return (float)Math.sin(angle);
|
||||
}
|
||||
|
||||
public final float cos(float angle) {
|
||||
return (float)Math.cos(angle);
|
||||
}
|
||||
|
||||
public final float tan(float angle) {
|
||||
return (float)Math.tan(angle);
|
||||
}
|
||||
|
||||
public final float atan2(float a, float b) {
|
||||
return (float)Math.atan2(a, b);
|
||||
}
|
||||
|
||||
|
||||
//public final float randomf() {
|
||||
//return ((float)Math.random() - 0.5f)*2.0f;
|
||||
//}
|
||||
|
||||
//public final float randomuf() {
|
||||
//return (float)Math.random();
|
||||
//}
|
||||
|
||||
public final float random(float howbig) {
|
||||
return (float)Math.random() * howbig;
|
||||
}
|
||||
|
||||
public final float random(float howsmall, float howbig) {
|
||||
float diff = howbig - howsmall;
|
||||
return howsmall + (float)Math.random() * diff;
|
||||
}
|
||||
|
||||
public final int random(int howbig) {
|
||||
return (int) (Math.random() * (double)howbig);
|
||||
}
|
||||
|
||||
public final int random(int howsmall, int howbig) {
|
||||
double diff = howbig - howsmall;
|
||||
return howsmall + (int) (Math.random() * diff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user