Hg200

Joined 29 March 2020
15 bytes removed ,  3 January 2021
m
no edit summary
mNo edit summary
mNo edit summary
Line 66: Line 66:
== The role of "x_gl_mat2" ==
== The role of "x_gl_mat2" ==


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 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 80: Line 80:
   get (hax, "position");
   get (hax, "position");


In the following simplified code section the matrix "x_projection" is assembled. It is used to scale the image of the above transformation into the bounding box of the window. 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:


{{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 114: Line 114:
</syntaxhighlight>}}
</syntaxhighlight>}}


"x_viewport" is a 2D transformation used to place the "normalized" plot box in the center of the bounding box:
"x_viewport" is a transformation used to place the "normalized" plot box in the center and to scale it 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">
Line 138: Line 138:
</syntaxhighlight>}}
</syntaxhighlight>}}


Note: The matrix "x_gl_mat2" just scales x, y so that the image fits tightly into the bounding box. 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!
20

edits