I am sorting a list of distances, but I would like to know the index of the distance in order to pass the corresponding point (points[j]) instead and not the distance. Something along these lines:
ArrayList<Float> distances = new ArrayList();
ArrayList<PVector> newPts = new ArrayList<PVector>();
Hi guys,
I have an arrayList called model which contains 3 other arrayLists called modelPart. modelPart are arrayLists of PVectors.
I would like to join all the PVectors of the 3 arrayLists modelParts in one new arrayList called nodes, but I don't know the correct syntax. Here is the code bit:
class Model
{
ArrayList <ModelPart> model;
Model()
{
model = new ArrayList<ModelPart>();
}
}
class ModelPart
{
ArrayList nodes;
ModelPart(ArrayList<PVector> p)
{
nodes = new ArrayList();
getPoints(p);
}
void getPoints(ArrayList<PVector> p)
{
for(int i = 0; i < mod.model.size(); ++i)
{
nodes.add(threshold.points);
}
}
void draw()
{
threshold.display();
nodes.clear();
///////////////////////////////////////////////this is my last bad tentative/////////////
for(int i = 0; i < mod.model.size(); ++i)
{
ModelPart mopa = mod.model.get(i);
for(int j = 0; j < mopa.threshold.points.size(); j++)
{
KinectThreshold n = (KinectThreshold)threshold.points.get(i);
nodes.add(n);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
println(nodes.size());
}
}
main:
void draw()
{
for(int i = 0; i < mod.model.size(); i++)
{
ModelPart mp = mod.model.get(i);
mp.draw();
}
}
void keyPressed()
{
if(key == ' ')
{
if (mod.model.size() < 3)
{
mod.model.add(new ModelPart(threshold.points)); //the vectors are coming form a threshold class with points
}
}
}
Hi guys,
Can I somehow call functions from classes to the second Applet?
All the examples I have seen to far are drawing simple primitives in the second applet like for instance (say that the second applet is called theApplet):
"theApplet.rect(theApplet.mouseX,10,100,100)"...
I wanted to have part of my sketch drawn on the main applet and part on the second applet still using classes. Would that be possible at all? Is there an example I could reference to?
Thanks a lot,
buzz
I have a geometry that is constantly chaging. I would like to hit some key and record how the geometry was on that frame it was captured and store it in an array list where I can add more frozen geometry and eventually recall them. Does anybody has an idea of how I could do that?
Thanks a lot,
buzz
Hi guys,
I have a question with regards to Daniel Shiffman's library openKinect.
I am trying to "take a picture" of my sketch and store it. The "picture" taken will be stored as an individual for a GA. The idea is to record the objects I am scanning and then when I got enough individuals to run a ga and evolve them according to my fitness function. But I am stuck on a really basic thing: How can I take the picture? In other words
how can I store the points of that particular frame the picture was taken. I have an array list of individuals already that adds individuals when I hit the space bar, but I didn't manage to freeze the frame, store and let it free again for the next individual...
Is this question kind of clear? Open to questions...
Thanks a lot for your help as always,
buzz
I have a question with regards to a project I am trying to do. I am using Daniel Shiffman's open Kinect library in combination with the Triangulate library. I am trying to find the normals of the triangles,but because the normals depend on the order of the triangles vertexes as their position changes constantly, the order of the triangles vertexes keeps on changing together and then not always I get the correct normal vector. So, my question is: Is there any other way other than cross product to find a perpendicular vector to a triangle? Thanks a lot for you time in advance. Buzz
Hi guys,
I am trying to understand what is wrong with the cross product. It is giving me some funky result when I normalize it. I guess its a simple one...really thankful if somebody could help. Here is the code:
Thanks a lot :)
buzz
// 4. pvector that follows the mouse - will be replaced by the sun
PVector m = new PVector(mouseX, mouseY, 300);
stroke(0);
line(g.x, g.y, g.z, m.x, m.y, m.z);
// 5. calcullate the angle between sun and normal vector
float angle = PVector.angleBetween(n, m);
//println(degrees(angle));
// 6. map the angle to a color value anf fill the triangle to that value
float mapping = map(angle, 0, 180, 0, 255); //possible angles to possible colours
//println(mapping);
strokeWeight(1);
stroke(0);
fill(mapping, 100, 100);
beginShape(TRIANGLES);
vertex(a.x, a.y, a.z);
vertex(b.x, b.y, b.z);
vertex(c.x, c.y, c.z);
endShape();
}