Search in sources :

Example 6 with Line

use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.

the class SpaceFlipper method flipVertically.

@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> flipVertically(Space<Coord2D> space) {
    Space<Coord2D> flippedSpace = new Space<>();
    Map<Station, Coord2D> stationMap = space.getStationMap();
    for (Station station : stationMap.keySet()) {
        Coord2D point = stationMap.get(station);
        flippedSpace.addStation(station, point.flipVertically());
    }
    Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
    for (Leg leg : legMap.keySet()) {
        Line<Coord2D> line = legMap.get(leg);
        Coord2D start = line.getStart();
        Coord2D end = line.getEnd();
        Line<Coord2D> flippedLine = new Line<>(start.flipVertically(), end.flipVertically());
        flippedSpace.addLeg(leg, flippedLine);
    }
    return flippedSpace;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 7 with Line

use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.

the class SpaceMover method move.

@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> move(Space<Coord2D> space, Coord2D delta) {
    Space<Coord2D> moved = new Space<>();
    Map<Station, Coord2D> stationMap = space.getStationMap();
    for (Station station : stationMap.keySet()) {
        Coord2D point = stationMap.get(station);
        moved.addStation(station, point.plus(delta));
    }
    Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
    for (Leg leg : legMap.keySet()) {
        Line<Coord2D> line = space.getLegMap().get(leg);
        Line<Coord2D> shiftedLine = new Line<>(line.getStart().plus(delta), line.getEnd().plus(delta));
        moved.addLeg(leg, shiftedLine);
    }
    return moved;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 8 with Line

use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.

the class CrossSection method getProjection.

public Space<Coord2D> getProjection() {
    Space<Coord2D> projection = new Space<>();
    projection.addStation(station, Coord2D.ORIGIN);
    for (Leg leg : station.getUnconnectedOnwardLegs()) {
        // first of all normalise to match the angle of the cross section
        Leg rotated = leg.rotate(-angle);
        Coord3D coord3D = Space3DUtils.toCartesian(Coord3D.ORIGIN, rotated);
        Coord2D coord2D = new Coord2D(coord3D.x, -coord3D.z);
        Line<Coord2D> line = new Line<>(Coord2D.ORIGIN, coord2D);
        projection.addLeg(rotated, line);
    }
    return projection;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Line(org.hwyl.sexytopo.model.graph.Line) Coord3D(org.hwyl.sexytopo.model.graph.Coord3D) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 9 with Line

use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.

the class Space3DTransformer method update.

protected synchronized void update(Space<Coord3D> space, Leg leg, Coord3D start) {
    Coord3D end = transform(start, leg);
    Line<Coord3D> line = new Line<>(start, end);
    space.addLeg(leg, line);
    if (leg.hasDestination()) {
        update(space, leg.getDestination(), end);
    }
}
Also used : Line(org.hwyl.sexytopo.model.graph.Line) Coord3D(org.hwyl.sexytopo.model.graph.Coord3D)

Example 10 with Line

use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.

the class Space2DUtils method transform.

@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> transform(Space<Coord2D> space, Coord2D point) {
    Space<Coord2D> newSpace = new Space<>();
    Map<Station, Coord2D> stations = space.getStationMap();
    for (Station station : stations.keySet()) {
        Coord2D coord = stations.get(station);
        Coord2D newCoord = coord.plus(point);
        newSpace.addStation(station, newCoord);
    }
    Map<Leg, Line<Coord2D>> legs = space.getLegMap();
    for (Leg leg : legs.keySet()) {
        Line<Coord2D> line = legs.get(leg);
        Line<Coord2D> newLine = transformLine(line, point);
        newSpace.addLeg(leg, newLine);
    }
    return newSpace;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Aggregations

Line (org.hwyl.sexytopo.model.graph.Line)10 Leg (org.hwyl.sexytopo.model.survey.Leg)8 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 Coord3D (org.hwyl.sexytopo.model.graph.Coord3D)4 Space (org.hwyl.sexytopo.model.graph.Space)4 Station (org.hwyl.sexytopo.model.survey.Station)4 Paint (android.graphics.Paint)1 Survey (org.hwyl.sexytopo.model.survey.Survey)1 Test (org.junit.Test)1