I've got a bit of code that takes compares entries in an array, but it's a hell of a mess and I'm sure there's a smarter way of doing it, I was wondering if anyone could point me in the right direction.
I've got an array of tab separated information in the format:
where each of the vars is a number between 1 and 7. What I want to do is compare each of the array entries, but only in the 'column' in which it's in, and where there's a match, work out the percentage correlation between the entries.
My current code relies on a set of nested
for loops:
As you can see this is a pretty ugly way of doing business. I was wondering if anyone had any suggestions for how to structure this snippet a bit more conveniently/economically/whatever?
I'm doing a visualization which looks at correlation percentages of nodes, which are laid out around a circle. At the moment, the correlations are represented by straight lines between the nodes, but for added clarity I'm wanting to use curved lines.
My geometry is worst than most 14 year olds, and I was wondering if anyone could help me with this? I've had a look at arc() and had a wee look at Toxiclib, but I'm unsure of where to start.
I'm using toArray to move data from a TreeSet to an array for ease of access in building an interface. When I use toArray in the function which uses the array theres no bother, i.e.
void someFunction(){
Float myArray[] = new Float[mySet.size()];
myArray = (Float[]) mySet.toArray(myArray);
// Can access individual elements of the array easily.
println(myArray[3]);
}
However, I think I'll be utilising the array in other places within the code, so I thought I could move the toArray code to setup(), however, when I do this, for some reason other functions can't see the Array i.e.
void setup() {
Float myArray[] = new Float[mySet.size()];
myArray = (Float[]) mySet.toArray(myArray);
}
void someFunction() {
// This will throw an error, couldn't find anything named myArray
println(myArray[3]);
}
I'm new to processing beyond the basics, but I'm intregued as to why this happens? I had a look at the docs for toArray and saw this:
The returned array will be "safe" in that no references to it are maintained by this collection