Browse Source

Math: doc++

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
a72ca4b2b6
  1. 8
      doc/matrix-vector.dox
  2. 11
      doc/types.dox
  3. 14
      src/Magnum/Math/Angle.h

8
doc/matrix-vector.dox

@ -121,7 +121,8 @@ Int[] mat = { 2, 4, 6,
1, 3, 5 }; 1, 3, 5 };
Math::Matrix2x3<Int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 } Math::Matrix2x3<Int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 }
@endcode @endcode
Note that unlike constructors, this function has no way to check whether the
Note that, unlike constructors, this function has no way to check whether the
array is long enough to contain all elements, so use with caution. array is long enough to contain all elements, so use with caution.
You can also *explicitly* convert between data types: You can also *explicitly* convert between data types:
@ -133,8 +134,7 @@ auto integral = Vector4i(floating); // {1, 2, -15, 7}
@section matrix-vector-component-access Accessing matrix and vector components @section matrix-vector-component-access Accessing matrix and vector components
Column vectors of matrices and vector components can be accessed using square Column vectors of matrices and vector components can be accessed using square
brackets, there is also round bracket operator for accessing matrix components brackets:
directly:
@code @code
Matrix3x2 a; Matrix3x2 a;
a[2] /= 2.0f; // third column (column major indexing, see explanation below) a[2] /= 2.0f; // third column (column major indexing, see explanation below)
@ -145,7 +145,7 @@ b[1] = 1; // second element
@endcode @endcode
Row vectors can be accessed too, but only for reading, and the access is slower Row vectors can be accessed too, but only for reading, and the access is slower
due to the way the matrix is stored (see explanation below): due to the way the matrix is stored (see @ref matrix-vector-column-major "explanation below"):
@code @code
Vector2i c = a.row(2); // third row Vector2i c = a.row(2); // third row
@endcode @endcode

11
doc/types.dox

@ -92,16 +92,17 @@ equivalently (e.g. @ref Math::Vector or @ref Color3 instead of @ref Vector3).
Other types, which don't have their GLSL equivalent, are: Other types, which don't have their GLSL equivalent, are:
- @ref Complex or @ref Complexd, @ref DualComplex or @ref DualComplexd - @ref Complex or @ref Complexd, @ref DualComplex or @ref DualComplexd
- @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or @ref DualQuaterniond - @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or
- @ref Range1D / @ref Range2D / @ref Range3D, @ref Range1Di / @ref Range2Di / @ref Range3Di or @ref DualQuaterniond
@ref Range1Dd / @ref Range2Dd / @ref Range3Dd - @ref Range1D / @ref Range2D / @ref Range3D, @ref Range1Di / @ref Range2Di /
@ref Range3Di or @ref Range1Dd / @ref Range2Dd / @ref Range3Dd
These types can be used in GLSL either by extracting values from their These types can be used in GLSL either by extracting values from their
underlying structure or converting them to types supported by GLSL (e.g. underlying structure or converting them to types supported by GLSL (e.g.
quaternion to matrix). quaternion to matrix).
For your convenience, there is also alias for class with often used constants -- For your convenience, there is also alias for class with often used constants
@ref Constants or @ref Constantsd. -- @ref Constants or @ref Constantsd.
- Previous page: @ref platform - Previous page: @ref platform
- Next page: @ref matrix-vector - Next page: @ref matrix-vector

14
src/Magnum/Math/Angle.h

@ -98,7 +98,7 @@ The requirement of explicit conversions from and to unitless types helps to
reduce unit-based errors. Consider following example with implicit conversions reduce unit-based errors. Consider following example with implicit conversions
allowed: allowed:
@code @code
Float std::sin(Float angle); namespace std { float sin(float angle); }
Float sine(Rad<Float> angle); Float sine(Rad<Float> angle);
Float a = 60.0f; // degrees Float a = 60.0f; // degrees
@ -110,13 +110,13 @@ std::sin(b); // silent error, std::sin() expected radians
These silent errors are easily avoided by requiring explicit conversions: These silent errors are easily avoided by requiring explicit conversions:
@code @code
//sine(angleInDegrees); // compilation error //sine(a); // compilation error
sine(Deg<Float>(angleInDegrees)); // explicitly specifying unit sine(Deg<Float>{a}); // explicitly specifying unit
//std::sin(angleInDegrees); // compilation error //std::sin(b); // compilation error
std::sin(Float(Rad<Float>(angleInDegrees)); // required explicit conversion hints std::sin(Float(Rad<Float>(b)); // required explicit conversion hints to user
// to user that this case needs special // that this case needs special attention
// attention (i.e., conversion to radians) // (i.e., conversion to radians)
@endcode @endcode
@see Magnum::Deg, Magnum::Degd @see Magnum::Deg, Magnum::Degd

Loading…
Cancel
Save