1 Reply Latest reply on Apr 29, 2010 10:41 PM by 794459

    Transformations

    843799
      Hello,

      I am trying to develop a graphical tool that can draw lines, cubes, spheres, triangles and polygon, The first three can be drawn by now. The triangle and polygon requires the code.

      I would like someone to give me a start with the transformation. The transformation is expected to take place when respective Jmenu options are selected. Can a sample code for a single transformation (let it be shearing along X-axis be provided). I can do the remaining in similar fashion. Also if possible tell me how to pick an individual object and conduct the transformations on it in the above said mode.

      The full code cannot be added due to the restriction of 7500. So I am adding the link to the same question that I asked in another forum.
      [http://forums.java.net/jive/thread.jspa?threadID=77010&tstart=0|http://forums.java.net/jive/thread.jspa?threadID=77010&tstart=0]

      What I require is this.
      menu = new JMenu("View");
      menu.add(createMenuItem("View", "Triangle", this));
      menu.add(createMenuItem("View", "Polygon", this));
      menuBar.add(menu);
      
      
      //public BranchGroup triangle() {
      
      /*Require code for Triangle /*
      
      //}
      
      //public BranchGroup polygon() {
      
      /*require code for Polygon*/
      
      //}
      
      public void shearx()
      {
          /*require sample code*/
      }
      
      
      else if (command.equals("Triangle"))
      {
      //triangle();
      
      }
      else if (command.equals("Polygon"))
      {
      //polygon();
      
      }
      }
      
      else if (menu.equals("Shear")) {
      if (command.equals("X-axis")) {
      
      //shearx();
      
              }
      
          }
      
      }
      }
      Thank you
        • 1. Re: Transformations
          794459
          Look up the Transform 3D class. It allows you to construct
          transformations using (I believe) arbitrary 4x4 homogeneous matrices. A
          shear transformation along the x-axis can be represented as something
          like:

          1 1 0 0
          0 1 0 0
          0 0 1 0
          0 0 0 1

          You might
          first want to look inside the Transform 3D class to see whether it has a
          predefined shear transformation, though.