-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Kango edited this page Apr 3, 2019
·
2 revisions
Welcome to the 3DSketches wiki!
nice solid 3D line use lights() at the beginning of draw()
void line3D(float x1, float y1, float z1,
float x2, float y2, float z2,
float weight, color colorLine)
// drawLine/line3D was programmed by James Carruthers
// see http://processing.org/discourse/yabb2/YaBB.pl?num=1262458611/0#9
{
// scale(90);
PVector p1 = new PVector(x1, y1, z1);
PVector p2 = new PVector(x2, y2, z2);
PVector v1 = new PVector(x2-x1, y2-y1, z2-z1);
float rho = sqrt(pow(v1.x, 2)+pow(v1.y, 2)+pow(v1.z, 2));
float phi = acos(v1.z/rho);
float the = atan2(v1.y, v1.x);
v1.mult(0.5);
pushMatrix();
PVector v2 = new PVector ( x1, y1, z1 );
translate(v2.x, v2.y, v2.z);
translate(v1.x, v1.y, v1.z);
rotateZ(the);
rotateY(phi);
noStroke();
fill(colorLine);
box(weight, weight, p1.dist(p2));
popMatrix();
} // method
//