use of org.twak.utils.collections.ConsecutivePairs in project chordatlas by twak.
the class Tube method tube.
public static void tube(MeshBuilder out, Collection<LinearForm3D> before, Collection<LinearForm3D> after, Line3d line, LinearForm3D left, LinearForm3D right, CrossGen gen) {
if (angle(before, line) < 0.1 || angle(after, line) < 0.1)
// too pointy to touch
return;
Point3d middle = line.fromPPram(0.5);
Vector3d along = line.dir();
along.normalize();
Vector3d nAlong = new Vector3d(along);
nAlong.negate();
Vector3d o1 = left.normal(), u1 = new Vector3d();
u1.cross(along, o1);
Frame frame = Mathz.buildFrame(o1, u1, along, middle);
Vector3d u2 = right.normal();
u2.cross(u2, along);
// u2.add( middle );
Vector2d leftDir = Mathz.toXY(frame, u1);
Vector2d rightDir = Mathz.toXY(frame, u2);
List<Point3d> profilePts = gen.gen(leftDir, rightDir).stream().map(p -> Mathz.fromXY(frame, p)).collect(Collectors.toList());
List<LinearForm3D> dummy = new ArrayList<>();
for (Pair<Point3d, Point3d> pair : new ConsecutivePairs<Point3d>(profilePts, true)) {
Point3d f1 = clip(pair.first(), along, after, dummy), f2 = clip(pair.second(), along, after, dummy), b1 = clip(pair.first(), nAlong, before, dummy), b2 = clip(pair.second(), nAlong, before, dummy);
out.add(f2, f1, b1, b2);
}
// cap( out, after , along, profilePts, true );
// cap( out, before, nAlong, profilePts, false );
}
use of org.twak.utils.collections.ConsecutivePairs in project chordatlas by twak.
the class Prof method findRoofLine.
public Point2d findRoofLine() {
double nonVertRun = 0;
Line up = new Line(0, 0, 0, 1);
Point2d runStart = null;
for (Pair<Point2d, Point2d> line : new ConsecutivePairs<>(this, false)) {
Line l = new Line(line.first(), line.second());
double angle = l.absAngle(up);
if (angle > Math.PI / 6 && angle < Math.PI) {
if (nonVertRun == 0)
runStart = l.start;
nonVertRun += l.length();
} else {
if (nonVertRun > 2 && runStart != null)
return runStart;
nonVertRun = 0;
}
}
return runStart == null ? get(size() - 1) : runStart;
}
Aggregations