86 lines
2.0 KiB
Plaintext
86 lines
2.0 KiB
Plaintext
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Method;
|
|
|
|
Point[] create_circle(float center_x, float center_y, float radius, int nb_point, int col){
|
|
Point[] line = new Point[nb_point + 1];
|
|
float px, py, factor;
|
|
|
|
for (int i = 0; i < line.length; i++){
|
|
factor = float(i) / float(line.length - 1);
|
|
px = center_x + radius * cos(factor * TWO_PI);
|
|
py = center_y + radius * sin(factor * TWO_PI);
|
|
line[i] = new Point(int(px), int(py), col);
|
|
}
|
|
return (line);
|
|
}
|
|
|
|
int getColInt(int r, int g, int b){
|
|
int col;
|
|
|
|
col = ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF));
|
|
return (col);
|
|
}
|
|
|
|
public void showFields(Object o) {
|
|
Class<?> clazz = o.getClass();
|
|
|
|
println("private fileds");
|
|
for(Field field : clazz.getDeclaredFields()) {
|
|
//you can also use .toGenericString() instead of .getName(). This will
|
|
//give you the type information as well.
|
|
|
|
println("\t", field.getName());
|
|
}
|
|
|
|
System.out.println("inherited fileds");
|
|
for(Field field : clazz.getFields()) {
|
|
//you can also use .toGenericString() instead of .getName(). This will
|
|
//give you the type information as well.
|
|
println("\t", field.getName());
|
|
}
|
|
}
|
|
|
|
public void showMethodes(Object o) {
|
|
Class<?> clazz = o.getClass();
|
|
|
|
System.out.println("private methode");
|
|
for(Method method : clazz.getDeclaredMethods()) {
|
|
println("\t", method.getName());
|
|
}
|
|
|
|
System.out.println("private methode");
|
|
for(Method method : clazz.getMethods()) {
|
|
println("\t", method.getName());
|
|
}
|
|
}
|
|
|
|
PVector vecSub(PVector a, PVector b){
|
|
PVector diff = new PVector();
|
|
|
|
diff.x = a.x - b.x;
|
|
diff.y = a.y - b.y;
|
|
diff.z = a.z - b.z;
|
|
return diff;
|
|
}
|
|
|
|
void normalize(PVector p){
|
|
float norme;
|
|
|
|
norme = sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
|
|
p.x /= norme;
|
|
p.y /= norme;
|
|
p.z /= norme;
|
|
}
|
|
|
|
PVector getNormalized(PVector v){
|
|
PVector res = new PVector(v.x, v.y, v.z);
|
|
|
|
normalize(res);
|
|
return (res);
|
|
}
|
|
|
|
|
|
float cross_product(PVector a, PVector b){
|
|
return (a.x*b.x + a.y*b.y + a.z*b.z);
|
|
}
|