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 };
Math::Matrix2x3<Int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 }
@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.
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
Column vectors of matrices and vector components can be accessed using square
brackets, there is also round bracket operator for accessing matrix components
directly:
brackets:
@code
Matrix3x2 a;
a[2] /= 2.0f; // third column (column major indexing, see explanation below)
@ -145,7 +145,7 @@ b[1] = 1; // second element
@endcode
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
Vector2i c = a.row(2); // third row
@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:
- @ref Complex or @ref Complexd, @ref DualComplex or @ref DualComplexd
- @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or @ref DualQuaterniond
- @ref Range1D / @ref Range2D / @ref Range3D, @ref Range1Di / @ref Range2Di / @ref Range3Di or
@ref Range1Dd / @ref Range2Dd / @ref Range3Dd
- @ref Quaternion or @ref Quaterniond, @ref DualQuaternion or
@ref DualQuaterniond
- @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
underlying structure or converting them to types supported by GLSL (e.g.
quaternion to matrix).
For your convenience, there is also alias for class with often used constants --
@ref Constants or @ref Constantsd.
For your convenience, there is also alias for class with often used constants
-- @ref Constants or @ref Constantsd.
- Previous page: @ref platform
- 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
allowed:
@code
Float std::sin(Float angle);
namespace std { float sin(float angle); }
Float sine(Rad<Float> angle);
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:
@code
//sine(angleInDegrees); // compilation error
sine(Deg<Float>(angleInDegrees)); // explicitly specifying unit
//sine(a); // compilation error
sine(Deg<Float>{a}); // explicitly specifying unit
//std::sin(angleInDegrees); // compilation error
std::sin(Float(Rad<Float>(angleInDegrees)); // required explicit conversion hints
// to user that this case needs special
// attention (i.e., conversion to radians)
//std::sin(b); // compilation error
std::sin(Float(Rad<Float>(b)); // required explicit conversion hints to user
// that this case needs special attention
// (i.e., conversion to radians)
@endcode
@see Magnum::Deg, Magnum::Degd

Loading…
Cancel
Save