My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package toxi.sim.dla;

import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Logger;

import toxi.geom.Line3D;
import toxi.geom.Vec3D;

public class DLAGuideLines {

protected static final Logger logger =
Logger.getLogger(DLAGuideLines.class.getName());

public SortedSet<DLASegment> segments;

public Iterator<DLASegment> iterator;

private double currT;

private DLASegment currSegment;

private Vec3D currPoint;

private Vec3D workDir;

public DLAGuideLines() {
this(new PipelineOrder());
}

public DLAGuideLines(Comparator<Line3D> comparator) {
segments = new TreeSet<DLASegment>(comparator);
}

@Deprecated
public DLAGuideLines addCurveStrip(List<Vec3D> points) {
return addPointList(points);
}

public DLAGuideLines addLine(Line3D l) {
return addLine(l.a, l.b);
}

public DLAGuideLines addLine(Vec3D a, Vec3D b) {
DLASegment s = new DLASegment(a, b, null);
logger.info("adding line segment: " + s);
segments.add(s);
return this;
}

public DLAGuideLines addPointList(List<Vec3D> points) {
int numP = points.size();
for (int i = 1; i < numP; i++) {
Vec3D p = i < numP - 1 ? points.get(i + 1) : null;
DLASegment s = new DLASegment(points.get(i - 1), points.get(i), p);
logger.info("adding curve segment: " + s);
segments.add(s);
}
return this;
}

public double getCurrentSegmentPos() {
return currT;
}

public Vec3D getDirection() {
if (workDir == null) {
getPoint();
}
return workDir;
}

public Vec3D getPoint() {
workDir =
currSegment.getDirection().interpolateToSelf(
currSegment.getNextDirection(), (float) currT);
workDir.normalize();
Vec3D v =
currPoint.add(workDir.scale(currSegment.getLength()
* (float) currT));
return v;
}

public boolean isComplete() {
return !iterator.hasNext() && currT >= 1.0;
}

public DLAGuideLines reset() {
iterator = segments.iterator();
currT = 0;
currSegment = iterator.next();
currPoint = currSegment.a.copy();
return this;
}

public DLASegment updatePoint(double delta) {
currT += delta;
if (currT >= 1.0) {
if (iterator.hasNext()) {
currT -= 1.0;
currSegment = iterator.next();
currPoint = currSegment.a.copy();
logger.info("next segment: " + currSegment);
}
}
return currSegment;
}
}

Change log

r442 by toxmeister on Feb 21, 2010   Diff
deprecting addCurveStip(), replacing with
addPointList()
Go to: 
Project members, sign in to write a code review

Older revisions

r409 by toxmeister on Feb 13, 2010   Diff
extracted DLA user parameters into
DLAConfiguration class, added
DLAEventAdapter, minor updates to
other DLA classes and removing DLATest
from package
r407 by toxmeister on Feb 13, 2010   Diff
minor updates to DLA & DLAGuidelines
and changes to default config & demo
r405 by toxmeister on Feb 11, 2010   Diff
fixing DLA classes, adding test/demo,
adding getters/setters for all
parameters
All revisions of this file

File info

Size: 2952 bytes, 111 lines
Powered by Google Project Hosting