Isolating x axis in 3D ArrayList
in
Programming Questions
•
2 years ago
Hi Guys,
I'm new to Processing so probably a fairly basic question but:
I have set up a 3D arraylist of nodes (points within a boundarybox).
I need to draw fibres (lines) between each node on the x axis moving incrementally along the y and z axis. I have created a very primitive fibre class...do I need to create a nested for loop to extract the necessary points?
Thanks,
Farley
void setup() {
nodeArray = new ArrayList();
for(int i = 0; i < numGroundX; i++) {
for(int j = 0; j < numGroundY; j++) {
for(int k = 0; k < numGroundZ; k++) {
Vec3D nodeOrigin = new Vec3D((i+0.5) * envX/numGroundX, (j+0.5) * envY/numGroundY, (k+0.5) * envZ/numGroundZ);
Node tmpNode = new Node(nodeOrigin);
nodeArray.add(tmpNode);
}
}
}
void draw() {
background(0);
for(int i = 0; i < nodeArray.size(); i++) {
Node tmpNode = (Node) nodeArray.get(i);
tmpNode.display();
}
void display() {
stroke(255,0,0);
strokeWeight(1);
point(nodeLoc.x,nodeLoc.y,nodeLoc.z);
}
I'm new to Processing so probably a fairly basic question but:
I have set up a 3D arraylist of nodes (points within a boundarybox).
I need to draw fibres (lines) between each node on the x axis moving incrementally along the y and z axis. I have created a very primitive fibre class...do I need to create a nested for loop to extract the necessary points?
Thanks,
Farley
void setup() {
nodeArray = new ArrayList();
for(int i = 0; i < numGroundX; i++) {
for(int j = 0; j < numGroundY; j++) {
for(int k = 0; k < numGroundZ; k++) {
Vec3D nodeOrigin = new Vec3D((i+0.5) * envX/numGroundX, (j+0.5) * envY/numGroundY, (k+0.5) * envZ/numGroundZ);
Node tmpNode = new Node(nodeOrigin);
nodeArray.add(tmpNode);
}
}
}
void draw() {
background(0);
for(int i = 0; i < nodeArray.size(); i++) {
Node tmpNode = (Node) nodeArray.get(i);
tmpNode.display();
}
void display() {
stroke(255,0,0);
strokeWeight(1);
point(nodeLoc.x,nodeLoc.y,nodeLoc.z);
}
1