the rotation is gradually getting slower and really laggy, anyone know why this is happening?
Many thanks, Callum
// ------------------------------------START------------------------------------
// ~variables & imports
import peasy.*;
ArrayList<PVector> points = new ArrayList<PVector>();
float u;
float v;
float tau;
static final int NUM_SHOW = 2;
// ------------------------------------SETUP------------------------------------
void setup() {
size(800, 800, P3D);
//background(20);
colorMode(HSB);
}
// -----------------------------------------------------------------------------
void draw() {
background(20);
for (float u = -TAU; u <= TAU; u += 0.04) {
for (float v = -1; v <= 1; v += 0.5) {
points.add(new PVector(hyperX(u, v, 2), hyperY(u, v, 2), hyperZ(u, v)));
}
}
showData();
}
// -----------------------------------------------------------------------------
void showData() {
translate(width/2, height/2, 0);
float t;
for (t = -TAU; t <= TAU; t+=0.1) {
float angleX = map(mouseX++, 0, width, t++, -TAU/4);
float angleY = map(mouseY++, 0, width, t++, TAU/4);
rotateY(angleY * 10);
rotateX(angleX);
}
noFill();
beginShape();
for (int i = 0; i < NUM_SHOW; i++) {
stroke(i, 180, 200);
for (PVector v : points) {
strokeWeight(2);
point(400 * v.x + i/10, 400 * v.y + i/100, 200 * v.z + i*10);
}
}
endShape();
}
// -----------------------------------------------------------------------------
// Parametric equations for hyperbolic helicoid
float hyperX(float u, float v, float tau) {
return (float)((Math.sinh(v) * cos(tau * u)) / (1 + Math.cosh(u) * Math.cosh(v)));
}
float hyperY(float u, float v, float tau) {
return (float)((Math.sinh(v) * sin(tau * u)) / (1 + Math.cosh(u) * Math.cosh(v)));
}
float hyperZ(float u, float v) {
return (float)((Math.cosh(v) * Math.sinh(u)) / (1 + Math.cosh(u) * Math.cosh(v)));
}
// -------------------------------------END-------------------------------------