EOS 2  1.1.0
Einfache Objektbasierte Sprache
SystemFunctions.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.base;
2 
3 import java.awt.Color;
4 import java.util.Calendar;
5 import java.util.Random;
11 public abstract class SystemFunctions {
12  private static final Random random = new Random();
13  public static Color colorFromRGBI(int r, int g, int b) {
14  return new Color(ri(r,0,255), ri(g,0,255), ri(b,0,255));
15  }
16  private static int ri(int value, int min, int max) {
17  if (value <= min) return min;
18  if (value >= max) return max;
19  return value;
20  }
21  public static Color colorFromRGBD(double r, double g, double b) {
22  return new Color(rf(r,0f,1f), rf(g,0f,1f), rf(b,0f,1f));
23  }
24  private static float rf(double value, float min, float max) {
25  if (value <= min) return min;
26  if (value >= max) return max;
27  return (float)value;
28  }
29  public static int round(double z) {
30  return (int)Math.round(z);
31  }
32  public static int floor(double z) {
33  return (int)Math.floor(z);
34  }
35  public static int random(int von, int bis) {
36  return random.nextInt(bis - von + 1) + von;
37  }
38  public static double abs(double z) {
39  return Math.abs(z);
40  }
41  public static double sqrt(double z) {
42  return Math.sqrt(z);
43  }
44  public static double sin(double alpha) {
45  return Math.sin(alpha/180*Math.PI);
46  }
47  public static double cos(double alpha) {
48  return Math.cos(alpha/180*Math.PI);
49  }
50  public static double tan(double alpha) {
51  return Math.tan(alpha/180*Math.PI);
52  }
53  public static double arctan(double m) {
54  return Math.atan(m)*180/Math.PI;
55  }
56  public static double arcsin(double m) {
57  return Math.asin(m)*180/Math.PI;
58  }
59  public static double arccos(double m) {
60  return Math.acos(m)*180/Math.PI;
61  }
62  public static double phi(double x, double y) {
63  double phi = Math.atan(y/x);
64  if (x < 0) {
65  return phi*180/Math.PI + 180;
66  } else {
67  return phi*180/Math.PI;
68  }
69  }
70  public static double r(double x, double y) {
71  return Math.sqrt(x*x+y*y);
72  }
73  public static int hour() {
74  return Calendar.getInstance().get(Calendar.HOUR);
75  }
76  public static int minute() {
77  return Calendar.getInstance().get(Calendar.MINUTE);
78  }
79  public static int second() {
80  return Calendar.getInstance().get(Calendar.SECOND);
81  }
82  public static int year() {
83  return Calendar.getInstance().get(Calendar.YEAR);
84  }
85  public static int month() {
86  return Calendar.getInstance().get(Calendar.MONTH);
87  }
88  public static int day() {
89  return Calendar.getInstance().get(Calendar.DATE);
90  }
91 
92 
93  public SystemFunctions() {}
94 }
static double r(double x, double y)
static double tan(double alpha)
static Color colorFromRGBI(int r, int g, int b)
static int random(int von, int bis)
static double cos(double alpha)
static Color colorFromRGBD(double r, double g, double b)
static double phi(double x, double y)
static double sin(double alpha)
Impressum