View Javadoc
1   package org.opentrafficsim.demo.network.xml;
2   
3   import java.awt.geom.AffineTransform;
4   import java.awt.geom.Path2D;
5   import java.awt.geom.Rectangle2D;
6   
7   import org.opentrafficsim.core.geometry.OTSGeometryException;
8   import org.opentrafficsim.core.geometry.OTSShape;
9   
10  /**
11   * <p>
12   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
16   * initial version Apr 3, 2016 <br>
17   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
19   */
20  public class TestTransform
21  {
22  
23      /**
24       * 
25       */
26      public TestTransform()
27      {
28      }
29  
30      /**
31       * @param args a
32       * @throws OTSGeometryException on error
33       */
34      public static void main(String[] args) throws OTSGeometryException
35      {
36          double x = 200;
37          double y = 300;
38          double l = 4;
39          double w = 2;
40          Rectangle2D rect = new Rectangle2D.Double(-l / 2.0, -w / 2.0, l, w);
41          Path2D path = new Path2D.Double(rect);
42          AffineTransform t = new AffineTransform();
43          t.translate(x, y);
44          t.rotate(Math.toRadians(45));
45          path.transform(t);
46          OTSShape s = new OTSShape(path);
47          System.out.println(s);
48      }
49  
50      /** {@inheritDoc} */
51      @Override
52      public final String toString()
53      {
54          return "TestTransform []";
55      }
56  
57  }