User:Hg200: Difference between revisions

Jump to navigation Jump to search
132 bytes added ,  30 September 2020
Tags: Mobile edit Mobile web edit
Tags: Mobile edit Mobile web edit Advanced mobile edit
Line 11: Line 11:
== The role of "x_gl_mat1" ==
== The role of "x_gl_mat1" ==


The following section of code assembles the matrix "x_view", which is a subset of "x_gl_mat1". The matrix "x_gl_mat1" consists of multiple translations, scalings and one rotation operation.
The following section of code assembles 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.


{{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">
   // Unit length vector for direction of view "f"
   // Unit length vector for direction of view "f" and up vector "UP"
  // up vector "UP" scaled so that "s = f x UP" gets unit length
   ColumnVector F (c_center), f (F), UP (c_upv);
   ColumnVector F (c_center), f (F), UP (c_upv);
   normalize (f);
   normalize (f);
   normalize (UP);
   normalize (UP);
  // Scale "UP" vector, so that norm(f x UP) becomes 1
  if (std::abs (dot (f, UP)) > 1e-15)
    {
      double fa = 1 / sqrt (1 - f(2)*f(2));
      scale (UP, fa, fa, fa);
    }


   // Calculate the vector rejection UP onto f
   // Calculate the vector rejection UP onto f
20

edits

Navigation menu