public static Parallelogram fromTransformedUnitSquare()

in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/shape/Parallelogram.java [123:154]


    public static Parallelogram fromTransformedUnitSquare(final Transform<Vector2D> transform,
            final Precision.DoubleEquivalence precision) {

        final List<Vector2D> vertices = UNIT_SQUARE_VERTICES.stream()
                .map(transform).collect(Collectors.toList());

        final int len = vertices.size();
        final boolean preservesOrientation = transform.preservesOrientation();

        final List<LineConvexSubset> boundaries = new ArrayList<>(UNIT_SQUARE_VERTICES.size());

        Vector2D p0;
        Vector2D p1;
        LineConvexSubset boundary;
        for (int i = 0; i < len; ++i) {
            p0 = vertices.get(i);
            p1 = vertices.get((i + 1) % len);

            if (precision.eqZero(p0.distance(p1))) {
                throw new IllegalArgumentException(MessageFormat.format(
                        "Parallelogram has zero size: vertices {0} and {1} are equivalent", p0, p1));
            }

            boundary = preservesOrientation ?
                    Lines.segmentFromPoints(p0, p1, precision) :
                    Lines.segmentFromPoints(p1, p0, precision);

            boundaries.add(boundary);
        }

        return new Parallelogram(boundaries);
    }