User:Hg200: Difference between revisions

Jump to navigation Jump to search
228 bytes added ,  3 January 2021
m
no edit summary
mNo edit summary
mNo edit summary
Line 16: Line 16:


== The role of "x_gl_mat1" ==
== The role of "x_gl_mat1" ==
=== x_view ===


The following section of code composes the matrix "x_view", which is a subset of "x_gl_mat1". The matrix "x_gl_mat1" consists of multiple translations, scales and one rotation operation.
The following section of code composes the matrix "x_view", which is a major subset of "x_gl_mat1". The matrix "x_gl_mat1" consists of multiple translations, scales and one rotation operation. Hint: A visualization of the individual operation steps is shown in a picture below.


{{Code|Section of axes::properties::update_camera ()"|<syntaxhighlight lang="C" style="font-size:13px">
{{Code|Section of axes::properties::update_camera ()"|<syntaxhighlight lang="C" style="font-size:13px">
Line 56: Line 57:
</syntaxhighlight>}}
</syntaxhighlight>}}


To visualize the matrix properties, the "x_gl_mat1" matrix is multiplied by the object coordinates. The plot box is now aligned with the Z-axis and the view point is at the origin <math display="inline">[0,0,0]</math>. The matrix transforms world coordinates into camera coordinates. The purple planes show the near and far clipping planes.
=== x_gl_mat1 ===
 
To visualize the matrix properties, the "x_gl_mat1" matrix is multiplied by the object coordinates. After the transformation, the plot box is aligned with the Z-axis and the view point is at the origin <math display="inline">[0,0,0]</math>. The matrix transforms world coordinates into camera coordinates. The purple planes show the near and far clipping planes.


[[File:Octave_x_gl_mat1_setup.png|center|250px]]
[[File:Octave_x_gl_mat1_setup.png|center|250px]]
Line 65: Line 68:


== The role of "x_gl_mat2" ==
== The role of "x_gl_mat2" ==
=== Bounding box ===


The matrix "x_gl_mat2" is composed of the sub matrices "x_viewport" and "x_projection". The purpose of these matrices is to fit the associated 2D image of the above transformation result into a "bounding box". The bounding box is defined as follows:
The matrix "x_gl_mat2" is composed of the sub matrices "x_viewport" and "x_projection". The purpose of these matrices is to fit the associated 2D image of the above transformation result into a "bounding box". The bounding box is defined as follows:


  bb(0), bb(1): Position of the viewport
* bb(0), bb(1): Position of the viewport
  bb(2), bb(3): Width and height of the viewport
* bb(2), bb(3): Width and height of the viewport


Hint: If you debug in "update_camera ()", you can print "bb":   
Hint: If you debug in "update_camera ()", you can print "bb":   
Line 75: Line 80:
   (gdb) print *bb.rep.data@bb.rep.len
   (gdb) print *bb.rep.data@bb.rep.len


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


   hax = axes ();
   hax = axes ();
   get (hax, "position");
   get (hax, "position");
=== x_projection ===


In the following simplified code section the matrix "x_projection" is assembled. It is used to normalize the image of the above transformation. For this purpose, the field of view (FOV) must be calculated:
In the following simplified code section the matrix "x_projection" is assembled. It is used to normalize the image of the above transformation. For this purpose, the field of view (FOV) must be calculated:
Line 114: Line 121:
</syntaxhighlight>}}
</syntaxhighlight>}}


"x_viewport" is a transformation used to place the "normalized" plot box in the center and to scale it into the bounding box:
=== x_viewport ===
 
"x_viewport" is a transformation used to place the previously "normalized" plot box in the center and to fit it tightly into the bounding box:


{{Code|Section of axes::properties::update_camera ()"|<syntaxhighlight lang="C" style="font-size:13px">
{{Code|Section of axes::properties::update_camera ()"|<syntaxhighlight lang="C" style="font-size:13px">
20

edits

Navigation menu