【发布时间】:2015-02-17 09:46:21
【问题描述】:
我正在处理中实现一些光线跟踪,并且正在使用数组列表来对交叉点进行排序并创建一个遮罩。现在我想使用处理js将这些草图上传到网络上。在我实现 arraylist 之前,我已经尝试上传草图并且它们起作用了。
相关代码如下:
import java.util.*;
ArrayList<Intersection> myIntersects;
void setup(){
myIntersects = new ArrayList<Intersection>();
//some code initializing the intersections and adding them to the arraylist
}
void draw(){
Collections.sort(myIntersects);
}
class Intersection implements Comparable<Intersection> {
float angle;
//constructor and other functions
public int compareTo(Intersection intersect){
int result = 0;
float temp = angle - intersect.angle;
if (temp < 0){
result = -1;
} else if (temp > 0){
result = 1;
} else {
result = 0;
}
return result;
}
有没有办法对处理js允许的交叉点进行排序? (或者可能是处理 js 的扩展,以便允许排序)
感谢您的帮助。
【问题讨论】:
标签: java sorting arraylist processing