src/main/java/de/javagl/geom/Lines.java
/**
     * Rotate the given source line around its starting point, by
     * the given angle, and stores the result in the given
     * destination line. If the destination line is <code>null</code>,
     * then a new line will be created and returned.<br>
     * <br>
     * This method is equivalent to 
     * <code>
     * Lines.transform(AffineTransform.getRotateInstance(angleRad, 
     *     lineSrc.getX1(), lineSrc.getY1()), lineSrc, lineDst);
     * </code>
     * but may be more efficient and convenient
     * 
     * @param angleRad The rotation angle
     * @param lineSrc The source line
     * @param lineDst The destination line
     * @return The destination line
     */
Rotate the given source line around its starting point, by
the given angle, and stores the result in the given
destination line. If the destination line is null,
then a new line will be created and returned.

This method is equivalent to

Lines.transform(AffineTransform.getRotateInstance(angleRad,
lineSrc.getX1(), lineSrc.getY1()), lineSrc, lineDst);

but may be more efficient and convenient

@param angleRad The rotation angle
@param lineSrc The source line
@param lineDst The destination line
@return The destination line
Rotate the given source line around its starting point by the given angle and stores the result in the given destination line . If the destination line is null then a new line will be created and returned . This method is equivalent to Lines . transform ( AffineTransform . getRotateInstance ( angleRad lineSrc . getX1 () lineSrc . getY1 () ) lineSrc lineDst ) ; but may be more efficient and convenient @param angleRad The rotation angle @param lineSrc The source line @param lineDst The destination line @return The destination line
public static Line2D rotate(
        double angleRad, Line2D lineSrc, Line2D lineDst)
    {
        double x0 = lineSrc.getX1();
        double y0 = lineSrc.getY1();
        double x1 = lineSrc.getX2();
        double y1 = lineSrc.getY2();
        double dx = x1 - x0;
        double dy = y1 - y0;
        double sa = Math.sin(angleRad);
        double ca = Math.cos(angleRad);
        double nx = ca * dx - sa * dy;
        double ny = sa * dx + ca * dy;
        if (lineDst == null)
        {
            lineDst = new Line2D.Double();
        }
        lineDst.setLine(x0, y0, x0+nx, y0+ny);
        return lineDst;
    }
public static Line2D rotate ( double angleRad , Line2D lineSrc , Line2D lineDst ) { double x0 = lineSrc . getX1 ( ) ; double y0 = lineSrc . getY1 ( ) ; double x1 = lineSrc . getX2 ( ) ; double y1 = lineSrc . getY2 ( ) ; double dx = x1 - x0 ; double dy = y1 - y0 ; double sa = Math . sin ( angleRad ) ; double ca = Math . cos ( angleRad ) ; double nx = ca * dx - sa * dy ; double ny = sa * dx + ca * dy ; if ( lineDst == null ) { lineDst = new Line2D . Double ( ) ; } lineDst . setLine ( x0 , y0 , x0 + nx , y0 + ny ) ; return lineDst ; }
Rotate the given source line around its starting point, by
 the given angle, and stores the result in the given
 destination line.
Rotate the given source line around its starting point by the given angle and stores the result in the given destination line .