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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations