Search in sources :

Example 1 with ConsecutivePairs

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 );
}
Also used : ConsecutivePairs(org.twak.utils.collections.ConsecutivePairs) LinearForm3D(org.twak.utils.geom.LinearForm3D) Collection(java.util.Collection) MultiMap(org.twak.utils.collections.MultiMap) MeshBuilder(org.twak.siteplan.jme.MeshBuilder) Vector2d(javax.vecmath.Vector2d) Pair(org.twak.utils.Pair) Collectors(java.util.stream.Collectors) Vector3d(javax.vecmath.Vector3d) ArrayList(java.util.ArrayList) Frame(org.twak.utils.Mathz.Frame) Loop(org.twak.utils.collections.Loop) Point2d(javax.vecmath.Point2d) List(java.util.List) Map(java.util.Map) Mathz(org.twak.utils.Mathz) Line3d(org.twak.utils.geom.Line3d) Point3d(javax.vecmath.Point3d) Frame(org.twak.utils.Mathz.Frame) ConsecutivePairs(org.twak.utils.collections.ConsecutivePairs) Vector2d(javax.vecmath.Vector2d) Vector3d(javax.vecmath.Vector3d) Point3d(javax.vecmath.Point3d) ArrayList(java.util.ArrayList) LinearForm3D(org.twak.utils.geom.LinearForm3D)

Example 2 with ConsecutivePairs

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;
}
Also used : Line(org.twak.utils.Line) SuperLine(org.twak.viewTrace.SuperLine) ConsecutivePairs(org.twak.utils.collections.ConsecutivePairs) Point2d(javax.vecmath.Point2d)

Aggregations

Point2d (javax.vecmath.Point2d)2 ConsecutivePairs (org.twak.utils.collections.ConsecutivePairs)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Point3d (javax.vecmath.Point3d)1 Vector2d (javax.vecmath.Vector2d)1 Vector3d (javax.vecmath.Vector3d)1 MeshBuilder (org.twak.siteplan.jme.MeshBuilder)1 Line (org.twak.utils.Line)1 Mathz (org.twak.utils.Mathz)1 Frame (org.twak.utils.Mathz.Frame)1 Pair (org.twak.utils.Pair)1 Loop (org.twak.utils.collections.Loop)1 MultiMap (org.twak.utils.collections.MultiMap)1 Line3d (org.twak.utils.geom.Line3d)1 LinearForm3D (org.twak.utils.geom.LinearForm3D)1 SuperLine (org.twak.viewTrace.SuperLine)1