private Coordinate getControlPoint(LineSegment lineSeg) { double radius = lineSeg.getLength() * fraction; double radian = lineSeg.angle() + Math.toRadians(offsetDegree); double dx = lineSeg.p0.x + (Math.cos(radian) * radius); double dy = lineSeg.p0.y + (Math.sin(radian) * radius); return new Coordinate(dx, dy); } }
private double getAngleWithXAxis(Coordinate origin, Coordinate destination) { LineSegment s1 = new LineSegment(origin, destination); double angle = s1.angle(); if (angle < 0) { angle = 2 * Math.PI + angle; } return angle; }
private LineString exendLine(LineString segment, double fromOffset, double toOffset) { Coordinate[] coordinates = ((LineString) segment.clone()).getCoordinates(); LineSegment line = new LineSegment(); if (fromOffset > 0) { line.p0 = coordinates[0]; line.p1 = coordinates[1]; coordinates[0] = offset(line.p0, line.angle(), -fromOffset); } if (toOffset > 0) { line.p0 = coordinates[coordinates.length - 2]; line.p1 = coordinates[coordinates.length - 1]; coordinates[coordinates.length - 1] = offset(line.p1, line.angle(), toOffset); } return segment.getFactory().createLineString(coordinates); }