Skip to content
Snippets Groups Projects
Select Git revision
  • 8234b2cb65b2dfd77bc58cf1f803fc6931b71604
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

movePosition.h

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    movePosition.h 1.47 KiB
    #ifndef _MOVE_POSITION_H_
    #define _MOVE_POSITION_H_
    
    class movePosition {
     public:
      float win[3]; // window coordinates
      float wnr[3]; // world coordinates BEFORE rotation
      float s[3]; // scaling state when the event was recorded
      float t[3]; // translation state when the event was recorded
      movePosition()
      {
        for(int i = 0; i < 3; i++)
          win[i] = wnr[i] = s[i] = t[i] = 0.;
      }
      movePosition(const movePosition &instance)
      {
        for(int i = 0; i < 3; i++){
          win[i] = instance.win[i];
          wnr[i] = instance.wnr[i];
          s[i] = instance.s[i];
          t[i] = instance.t[i];
        }
      }
      void set(float scale[3], float translate[3], float vxmax, float vxmin,
               float vymin, float vymax, int width, int height, int x, int y)
      {
        for(int i = 0; i < 3; i++){
          s[i] = scale[i];
          t[i] = translate[i];
        }
        win[0] = (float)x;
        win[1] = (float)y;
        win[2] = 0.;
    
        wnr[0] =
          (vxmin + win[0] / (float)width * (vxmax - vxmin)) / scale[0] - translate[0];
        wnr[1] =
          (vymax - win[1] / (float)height * (vymax - vymin)) / scale[1] - translate[1];
        wnr[2] = 0.;
      }
      void recenter(float scale[3], float translate[3]) const
      {
        // compute the equivalent translation to apply *after* the scaling so that
        // the scaling is done around the point which was clicked:
        translate[0] = t[0] * (s[0] / scale[0]) - wnr[0] * (1. - (s[0] / scale[0]));
        translate[1] = t[1] * (s[1] / scale[1]) - wnr[1] * (1. - (s[1] / scale[1]));
      }
    };
    
    #endif