【发布时间】:2017-03-24 08:49:04
【问题描述】:
这是我的代码,显然它不正确?有没有其他方法可以在不重叠的随机位置创建对象?感谢您的宝贵时间。
public ArrayList getVector3f() {
boolean lessThan = false;
// create first random vector & add it to the list array
Vector3f v1 = randVector();
list.add(v1);
//num=4;
for (int i = 0; i <= num - 2; i++) {
vec = randVector();
for (int j = 0; j <= list.size() - 1 ; j++) {
if (list.get(j).distance(vec) < 4f) {
lessThan = true;
}
}
if (lessThan == true) {
vec = randVector();
for (int j = 0; j <= list.size() - 1; j++) {
if (list.get(j).distance(vec) < 4f) {
lessThan = true;
} else {
lessThan = false;
}
}
}
if (lessThan == false) {
list.add(vec);
System.out.println(vec);
}
}
return list;
}
【问题讨论】:
标签: java jmonkeyengine