Hello,
I believe that I have almost correctly drawn-out a hyperbolic helicoid:
(https://mathworld.wolfram.com/HyperbolicHelicoid.html).
But there is some odd behavior, I think it’s because I am not calculating torsion correctly, or it could be the casting from double to float.
/**
TITLE: Hyperbolic Helicoid
LAST UPDATED: Sunday 23nd March 2020
BY: Callum Clegg
DESC: This program 'draws' a wireframe hyperbolic helicoid (in Java).
*/
// -----------------------------------------------------------------------------
// Global variables/imports
import peasy.*;
ArrayList<PVector> points = new ArrayList<PVector>();
ArrayList<PVector> HP = new ArrayList<PVector>();
float p;
float u;
float v;
float tau;
PeasyCam cam;
// -----------------------------------------------------------------------------
void setup() {
size(800, 800, P3D);
background(20);
colorMode(HSB);
avoidClipping();
cam = new PeasyCam(this , 5000);
}
void draw() {
background(20);
//HELICOID
//points.add(new PVector(x(p), y(p), z(p)));
//p+=0.0521;
//showData();
for (float tau = -10; tau <= 10; tau+=0.05) {
HP.add(new PVector((float)hyperX(u, v, tau), (float)hyperY(u, v, tau), (float)hyperZ(u, v)));
u += 0.0005;
v += 0.01;
//tau += 0.01;
}
present();
}
// -----------------------------------------------------------------------------
void showData() {
noFill();
stroke(100,180,200);
strokeWeight(5);
translate(width / 2, height / 2);
beginShape();
for (PVector v : points) {
vertex(v.x, v.y, v.z);
}
endShape();
}
// -----------------------------------------------------------------------------
void present() {
noFill();
stroke(200,180,200);
strokeWeight(5);
translate(width / 2, height / 2);
beginShape();
for (PVector v : HP) {
vertex(v.x, v.y, v.z);
}
endShape();
}
// -----------------------------------------------------------------------------
// Parametric equations for hyperbolic helicoid
float torsion;
float tangent;
float normal;
float binormal;
double hyperX(float u, float v, float tau) {
return ((Math.sinh(v) * cos(tau * u)) / 1 + Math.cosh(u) * Math.cosh(v));
}
double hyperY(float u, float v, float tau) {
return ((Math.sinh(v) * sin(tau * u)) / 1 + Math.cosh(u) * Math.cosh(v));
}
double hyperZ(float u, float v) {
return ((Math.cosh(v) * Math.sinh(u)) / 1 + Math.cosh(u) * Math.cosh(v));
}
// -----------------------------------------------------------------------------
// Parametric equations for helicoid
float x(float p) {
return 1000 * cos(p);
}
float y(float p) {
return 1000 * sin(p);
}
float z(float p) {
return p*100; // return p?
}
// -----------------------------------------------------------------------------
// Reduce clipping (greater area in view of 'cam')
void avoidClipping() {
perspective(PI/3.0, (float) width/height, 1, 1000000);
}
// -------------------------------------END-------------------------------------
If anyone has any suggestions I would be most greatful.
Many thanks,
Callum