Editing User:Hg200

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 79: Line 79:


   (gdb) print *bb.rep.data@bb.rep.len
   (gdb) print *bb.rep.data@bb.rep.len
  (gdb) $1 = {72.79, 31.50, 434, 342.29}


Compare the result with the output on the Octave prompt:
Compare the result with the output on the Octave prompt:


   hax = axes ();
   hax = axes ();
   get (hax, "position")
   get (hax, "position");
  ans = 73.80 47.20 434.00 342.30
  get (gcf, 'position')
  ans = 22 300 560 420
 
Where 420 - 342.30 - 31.5 + 1 = 47.20


=== x_projection ===
=== x_projection ===
Line 118: Line 112:
     v_angle = get_cameraviewangle ();
     v_angle = get_cameraviewangle ();


   // x_projection: identity "diag([1, 1, 1, 1])"
   // x_projection = diag([1, 1, 1, 1])
   Matrix x_projection = xform_matrix ();
   Matrix x_projection = xform_matrix ();
   // Calculate backwards from the angle to the ratio. This step
   // Calculate backwards from the angle to the ratio. This step
Line 143: Line 137:
     pix = (bb(2) < bb(3) ? bb(2) : bb(3));
     pix = (bb(2) < bb(3) ? bb(2) : bb(3));


   // x_viewport: identity "diag([1, 1, 1, 1])"
   // x_viewport = diag([1, 1, 1, 1])
   Matrix x_viewport = xform_matrix ();
   Matrix x_viewport = xform_matrix ();
   // Move to the center of the bounding box inside the figure.
   // Move to the center of the bounding box inside the figure.
Line 153: Line 147:
</syntaxhighlight>}}
</syntaxhighlight>}}


Note: The matrix "x_gl_mat2" scales x, y. However the z-coordinate is not modified!
Note: The matrix "x_gl_mat2" scales x, y so that the image fits tightly into the bounding box. The z-coordinate is not modified!


= setup_opengl_transformation () =
= setup_opengl_transformation () =
Line 159: Line 153:
== OpenGL backend ==
== OpenGL backend ==


In the OpenGL backend, the view matrix, an orthographic matrix, and the viewport transform are used to transform the octave plot into the screen window.
In the OpenGL backend, the view matrix, an orthographic matrix, and the projection matrix are loaded on the matrix stack.


{{Code|Section of opengl_renderer::setup_opengl_transformation ()"|<syntaxhighlight lang="C" style="font-size:13px">
{{Code|Section of opengl_renderer::setup_opengl_transformation ()"|<syntaxhighlight lang="C" style="font-size:13px">
Line 175: Line 169:
   m_glfcns.glLoadIdentity ();
   m_glfcns.glLoadIdentity ();
   m_glfcns.glScaled (1, 1, -1);
   m_glfcns.glScaled (1, 1, -1);
   // Matrix x_gl_mat1
   // Matrix x_gl_mat2
   m_glfcns.glMultMatrixd (x_mat1.data ());
   m_glfcns.glMultMatrixd (x_mat1.data ());
   m_glfcns.glMatrixMode (GL_PROJECTION);
   m_glfcns.glMatrixMode (GL_PROJECTION);
Line 181: Line 175:


   Matrix vp = get_viewport_scaled ();
   Matrix vp = get_viewport_scaled ();
   // Install orthographic projection matrix with viewport
   // Install Orthographic Projection Matrix with viewport
   // setting "0, vp(2), vp(3), 0" and near / far values "xZ1, xZ2"
   // setting 0, vp(2), vp(3), 0 and near / far values xZ1, xZ2
   m_glfcns.glOrtho (0, vp(2), vp(3), 0, xZ1, xZ2);
   m_glfcns.glOrtho (0, vp(2), vp(3), 0, xZ1, xZ2);
   // Matrix x_gl_mat2
   // Matrix x_gl_mat2
Line 191: Line 185:


</syntaxhighlight>}}
</syntaxhighlight>}}
Hint: If you debug in "setup_opengl_transformation ()", you can print the viewport "vp": 
  (gdb) print *vp.rep.data@vp.rep.len
  (gdb) $1 = {0, 0, 560, 420}
This is consistent with the window size.
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: