Exemple #1
0
        public Line2D transform(TransformMatrix2D matrix)
        {
            Point2D startNew = matrix.multiply(start),
                    endNew   = matrix.multiply(end);

            return(new Line2D(startNew, endNew));
        }
Exemple #2
0
 public Polyline2D transform(TransformMatrix2D matrix)
 {
     Point2D[] vertexesNew = new Point2D[vertexes.Length];
     for (int i = 0; i < vertexes.Length; ++i)
     {
         vertexesNew[i] = matrix.multiply(vertexes[i]);
     }
     return(new Polyline2D(vertexesNew, _isClosed || (Util.compareDoubles(vertexesNew[0].getX(), vertexesNew[vertexes.Length - 1].getX()) && Util.compareDoubles(vertexesNew[0].getY(), vertexesNew[vertexes.Length - 1].getY()))));
 }
Exemple #3
0
 /**
  * @param center the center point of the ellipse.
  * @param rx the radius of the ellipse in X direction.
  * @param ry the radius of the ellipse in Y direction.
  */
 public Ellipse2D(Point2D center, double rx, double ry)
 {
     this.center           = center;
     this.horizontal       = new Vector2D(rx, 0.0d);
     this.horizontalLength = rx;
     this.vertical         = new Vector2D(0.0d, ry);
     this.verticalLength   = ry;
     this.angle            = 0.0d;
     this._transform       = TransformMatrix2D.UNITY_MATRIX;
     this.transformInverse = TransformMatrix2D.UNITY_MATRIX;
 }
Exemple #4
0
        public IGeometric2D transform(TransformMatrix2D matrix)
        {
            Point2D  centerNew         = matrix.multiply(center);
            Vector2D horizontalNew     = centerNew.vec(matrix.multiply(center.add(horizontal))),
                     verticalNew       = centerNew.vec(matrix.multiply(center.add(vertical)));
            double radiusHorizontalNew = horizontalNew.length();
            double radiusVerticalNew   = verticalNew.length();

            if (Util.compareDoubles(radiusHorizontalNew, radiusVerticalNew))
            {
                //Transform let this ellipse become a circle.
                return(new Circle2D(centerNew, radiusHorizontalNew));
            }
            return(new Ellipse2D(centerNew, horizontalNew, verticalNew));
        }
Exemple #5
0
        public IGeometric2D transform(TransformMatrix2D matrix)
        {
            Point2D lowerLeftNew  = matrix.multiply(lowerLeft);
            Point2D upperRightNew = matrix.multiply(upperRight);
            Point2D upperLeftNew  = matrix.multiply(upperLeft);
            Point2D lowerRightNew = matrix.multiply(lowerRight);

            if (!Util.compareDoubles(lowerLeftNew.getY(), lowerRightNew.getY()) || !Util.compareDoubles(upperLeftNew.getY(), upperRightNew.getY()) || !Util.compareDoubles(lowerLeftNew.getX(), upperLeftNew.getX()) || !Util.compareDoubles(lowerRightNew.getX(), upperRightNew.getX()))
            {
                Point2D[] vertexes = new Point2D[4];
                vertexes[0] = lowerLeftNew;
                vertexes[1] = lowerRightNew;
                vertexes[2] = upperRightNew;
                vertexes[3] = upperLeftNew;
                return(new Polyline2D(vertexes, true));
            }
            return(new Rect2D(lowerLeftNew, upperRightNew));
        }
Exemple #6
0
        public IGeometric2D transform(TransformMatrix2D matrix)
        {
            Point2D  centerNew  = matrix.multiply(center);
            Point2D  maxXNew    = matrix.multiply(new Point2D(center.getX() + radius, center.getY()));
            Point2D  maxYNew    = matrix.multiply(new Point2D(center.getX(), center.getY() + radius));
            Vector2D vectorXNew = centerNew.vec(maxXNew);
            Vector2D vectorYNew = centerNew.vec(maxYNew);
            double   radiusXNew = vectorXNew.length();
            double   radiusYNew = vectorYNew.length();

            if (Util.compareDoubles(radiusXNew, radiusYNew))
            {
                //Transform let this circle stay a circle.
                return(new Circle2D(centerNew, radiusXNew));
            }
            if (Util.compareDoubles(maxXNew.getY(), centerNew.getY()) && Util.compareDoubles(maxYNew.getX(), centerNew.getX()))
            {
                //Transform let this circle become a ellipse, but it is not rotated.
                return(new Ellipse2D(centerNew, radiusXNew, radiusYNew));
            }
            //Transform let this circle become a rotated ellipse.
            return(new Ellipse2D(centerNew, vectorXNew, vectorYNew));
        }
Exemple #7
0
 /**
  * @param center the center point of the ellipse.
  * @param horizontal the horizontal radius of the ellipse as a vector.
  * @param vertical the vertical radius of the ellipse as a vector.
  */
 public Ellipse2D(Point2D center, Vector2D horizontal, Vector2D vertical)
 {
     this.center = center;
     if (Util.compareDoubles(horizontal.getX(), 0.0d) && Util.compareDoubles(vertical.getY(), 0.0d))
     {
         this.horizontal = vertical;
         this.vertical   = horizontal;
     }
     else
     {
         this.horizontal = horizontal;
         this.vertical   = vertical;
     }
     this.horizontalLength = this.horizontal.length();
     this.verticalLength   = this.vertical.length();
     if (Util.compareDoubles(this.horizontal.getY(), 0.0d) && Util.compareDoubles(this.vertical.getX(), 0.0d))
     {
         this.angle            = 0.0d;
         this._transform       = TransformMatrix2D.UNITY_MATRIX;
         this.transformInverse = TransformMatrix2D.UNITY_MATRIX;
     }
     else
     {
         if (Util.compareDoubles(this.horizontal.getX(), 0.0d))
         {
             this.angle = Vector2D.Y_VECTOR.angleTo(this.vertical);
         }
         else
         {
             this.angle = Vector2D.X_VECTOR.angleTo(this.horizontal);
         }
         TransformMatrix2D result = TransformMatrix2D.translate(center.getX(), center.getY());
         result                = result.multiply(TransformMatrix2D.rotate(-this.angle));
         this._transform       = result.multiply(TransformMatrix2D.translate(-center.getX(), -center.getY()));
         this.transformInverse = this._transform.inverse();
     }
 }
Exemple #8
0
 IGeometric2D IGeometric2D.transform(TransformMatrix2D matrix)
 {
     return(transform(matrix));
 }