Browse Source

Math: updates for the new documentation theme.

pull/225/head
Vladimír Vondruš 8 years ago
parent
commit
05bb8b419a
  1. 8
      src/Magnum/Math/Algorithms/GaussJordan.h
  2. 6
      src/Magnum/Math/Algorithms/KahanSum.h
  3. 17
      src/Magnum/Math/Algorithms/Svd.h
  4. 51
      src/Magnum/Math/Angle.h
  5. 24
      src/Magnum/Math/Bezier.h
  6. 8
      src/Magnum/Math/BoolVector.h
  7. 139
      src/Magnum/Math/Color.h
  8. 3
      src/Magnum/Math/Dual.h
  9. 14
      src/Magnum/Math/DualComplex.h
  10. 15
      src/Magnum/Math/Functions.h
  11. 6
      src/Magnum/Math/Half.h
  12. 3
      src/Magnum/Math/Matrix.h
  13. 4
      src/Magnum/Math/Matrix3.h
  14. 12
      src/Magnum/Math/Matrix4.h
  15. 27
      src/Magnum/Math/Packing.h
  16. 5
      src/Magnum/Math/Range.h
  17. 18
      src/Magnum/Math/RectangularMatrix.h
  18. 15
      src/Magnum/Math/Swizzle.h
  19. 3
      src/Magnum/Math/TypeTraits.h
  20. 13
      src/Magnum/Math/Vector.h
  21. 8
      src/Magnum/Math/Vector2.h
  22. 8
      src/Magnum/Math/Vector3.h

8
src/Magnum/Math/Algorithms/GaussJordan.h

@ -50,7 +50,7 @@ reasons, only pure Gaussian elimination is done on @p a and the final
backsubstitution is done only on @p t, as @p a would always end with identity
matrix anyway.
Based on ultra-compact Python code by Jarno Elonen,
Based on an ultra-compact Python code by Jarno Elonen,
http://elonen.iki.fi/code/misc-notes/python-gaussj/index.html.
*/
template<std::size_t size, std::size_t rows, class T> bool gaussJordanInPlaceTransposed(RectangularMatrix<size, size, T>& a, RectangularMatrix<size, rows, T>& t) {
@ -114,9 +114,9 @@ template<std::size_t size, std::size_t cols, class T> bool gaussJordanInPlace(Re
/**
@brief Gauss-Jordan matrix inversion
Since @f$ (\boldsymbol{A}^{-1})^T = (\boldsymbol{A}^T)^{-1} @f$, passes @p a
and an identity matrix to @ref gaussJordanInPlaceTransposed() and returns the
inverted matrix. Expects that the matrix is invertible.
Since @f$ (\boldsymbol{A}^{-1})^T = (\boldsymbol{A}^T)^{-1} @f$, passes
@p matrix and an identity matrix to @ref gaussJordanInPlaceTransposed();
returning the inverted matrix. Expects that the matrix is invertible.
@see @ref Matrix::inverted()
*/
template<std::size_t size, class T> Matrix<size, T> gaussJordanInverted(Matrix<size, T> matrix) {

6
src/Magnum/Math/Algorithms/KahanSum.h

@ -48,7 +48,8 @@ significantly reduces numerical error in the total. See Wikipedia for an
in-depth explanation: https://en.wikipedia.org/wiki/Kahan_summation_algorithm
Example with summation of a hundred million ones:
@code
@code{.cpp}
std::vector<Float> data(100000000, 1.0f);
Float a = std::accumulate(data.begin(), data.end()); // 1.667e7f
Float b = Math::Algorithms::kahanSum(data.begin(), data.end()); // 1.000e8f
@ -58,7 +59,8 @@ If required, it is also possible to use this algorithm on non-contiguous ranges
or single values (for example when calculating sum of pixel values in an image
with some row padding or when the inputs are generated / converted from other
values):
@code
@code{.cpp}
Containers::ArrayView<UnsignedByte> pixels;
Float sum = 0.0f, c = 0.0f;
for(UnsignedByte pixel: pixels) {

17
src/Magnum/Math/Algorithms/Svd.h

@ -68,23 +68,24 @@ zero matrices.
Full @f$ U @f$, @f$ \Sigma @f$ matrices and original @f$ M @f$ matrix can be
reconstructed from the values as following:
@code
RectangularMatrix<cols, rows, Double> m;
RectangularMatrix<cols, rows, Double> uPart;
Vector<cols, Double> wDiagonal;
Matrix<cols, Double> v;
@code{.cpp}
Math::RectangularMatrix<cols, rows, Double> m;
Math::RectangularMatrix<cols, rows, Double> uPart;
Math::Vector<cols, Double> wDiagonal;
Math::Matrix<cols, Double> v;
std::tie(uPart, wDiagonal, v) = Math::Algorithms::svd(m);
// Extend U
Matrix<rows, Double> u(Matrix<rows, Double>::Zero);
Math::Matrix<rows, Double> u(Matrix<rows, Double>::Zero);
for(std::size_t i = 0; i != rows; ++i)
u[i] = uPart[i];
// Diagonal W
RectangularMatrix<cols, rows, Double> w =
RectangularMatrix<cols, rows, Double>::fromDiagonal(wDiagonal);
Math::RectangularMatrix<cols, rows, Double> w =
Math::RectangularMatrix<cols, rows, Double>::fromDiagonal(wDiagonal);
// u*w*v.transposed() == m
@endcode

51
src/Magnum/Math/Angle.h

@ -42,22 +42,24 @@ namespace Magnum { namespace Math {
/**
@brief Angle in degrees
Along with Rad provides convenience classes to make angle specification and
conversion less error-prone.
Along with @ref Rad provides convenience classes to make angle specification
and conversion less error-prone.
## Usage
@section Math-Deg-usage Usage
You can enter the value either by using literal:
@code
You can enter the value either by using a literal:
@code{.cpp}
using namespace Literals;
auto degrees = 60.0_degf; // type is Deg<Float>
auto radians = 1.047_rad; // type is Rad<Double>
@endcode
Or explicitly convert unitless value (such as output from some function) to
Or explicitly convert a unitless value (such as output from some function) to
either degrees or radians:
@code
@code{.cpp}
Double foo();
Deg<Float> degrees(35.0f);
@ -66,8 +68,9 @@ Rad<Double> radians(foo());
@endcode
The classes support all arithmetic operations, such as addition, subtraction
or multiplication/division by unitless number:
@code
or multiplication/division by a unitless number:
@code{.cpp}
auto a = 60.0_degf + 17.35_degf;
auto b = -a + 23.0_degf*4;
//auto c = 60.0_degf*45.0_degf; // error, undefined resulting unit
@ -76,7 +79,8 @@ auto b = -a + 23.0_degf*4;
It is also possible to compare angles with all comparison operators, but
comparison of degrees and radians is not possible without explicit conversion
to common type:
@code
@code{.cpp}
Rad<Float> angle();
Deg<Float> x = angle(); // convert to degrees for easier comparison
@ -85,8 +89,9 @@ if(x < 30.0_degf) foo();
@endcode
It is possible to seamlessly convert between degrees and radians and explicitly
convert the value back to underlying type:
@code
convert the value back to the underlying type:
@code{.cpp}
Float sine(Rad<Float> angle);
Float a = sine(60.0_degf); // the same as sine(1.047_radf)
Deg<Double> b = 1.047_rad; // the same as 60.0_deg
@ -94,12 +99,13 @@ Float d = Double(b); // 60.0
//Float e = b; // error, no implicit conversion
@endcode
## Requirement of explicit conversion
@section Math-Angle-explicit-conversion Requirement of explicit conversion
The requirement of explicit conversions from and to unitless types helps to
reduce unit-based errors. Consider following example with implicit conversions
allowed:
@code
@code{.cpp}
namespace std { float sin(float angle); }
Float sine(Rad<Float> angle);
@ -111,7 +117,8 @@ std::sin(b); // silent error, std::sin() expected radians
@endcode
These silent errors are easily avoided by requiring explicit conversions:
@code
@code{.cpp}
//sine(a); // compilation error
sine(Deg<Float>{a}); // explicitly specifying unit
@ -153,8 +160,7 @@ template<class T> class Deg: public Unit<Deg, T> {
/**
* @brief Construct degrees from radians
*
* Performs conversion from radians to degrees, i.e.:
* @f[
* Performs conversion from radians to degrees, i.e.: @f[
* deg = 180 \frac {rad} \pi
* @f]
*/
@ -167,10 +173,12 @@ namespace Literals {
@brief Double-precision degree value literal
Example usage:
@code
@code{.cpp}
Double cosine = Math::cos(60.0_deg); // cosine = 0.5
Double cosine = Math::cos(1.047_rad); // cosine = 0.5
@endcode
@see @link operator""_degf() @endlink, @link operator""_rad() @endlink
*/
constexpr Deg<Double> operator "" _deg(long double value) { return Deg<Double>(Double(value)); }
@ -179,10 +187,12 @@ constexpr Deg<Double> operator "" _deg(long double value) { return Deg<Double>(D
@brief Single-precision degree value literal
Example usage:
@code
@code{.cpp}
Float tangent = Math::tan(60.0_degf); // tangent = 1.732f
Float tangent = Math::tan(1.047_radf); // tangent = 1.732f
@endcode
@see @link operator""_deg() @endlink, @link operator""_radf() @endlink
*/
constexpr Deg<Float> operator "" _degf(long double value) { return Deg<Float>(Float(value)); }
@ -225,8 +235,7 @@ template<class T> class Rad: public Unit<Rad, T> {
/**
* @brief Construct radians from degrees
*
* Performs conversion from degrees to radians, i.e.:
* @f[
* Performs conversion from degrees to radians, i.e.: @f[
* rad = deg \frac \pi 180
* @f]
*/

24
src/Magnum/Math/Bezier.h

@ -182,8 +182,8 @@ template<UnsignedInt order, UnsignedInt dimensions, class T> class Bezier {
/**
@brief Quadratic Bézier curve
Convenience alternative to `Bezier<2, dimensions, T>`. See @ref Bezier for more
information.
Convenience alternative to @cpp Bezier<2, dimensions, T> @ce. See @ref Bezier
for more information.
@see @ref QuadraticBezier2D, @ref QuadraticBezier3D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
@ -193,8 +193,8 @@ template<UnsignedInt dimensions, class T> using QuadraticBezier = Bezier<2, dime
/**
@brief Two-dimensional quadratic Bézier curve
Convenience alternative to `QuadraticBezier<2, T>`. See @ref QuadraticBezier
and @ref Bezier for more information.
Convenience alternative to @cpp QuadraticBezier<2, T> @ce. See
@ref QuadraticBezier and @ref Bezier for more information.
@see @ref QuadraticBezier3D, @ref Magnum::QuadraticBezier2D,
@ref Magnum::QuadraticBezier2Dd
*/
@ -205,8 +205,8 @@ template<class T> using QuadraticBezier2D = QuadraticBezier<2, T>;
/**
@brief Three-dimensional quadratic Bézier curve
Convenience alternative to `QuadraticBezier<3, T>`. See @ref QuadraticBezier
and @ref Bezier for more information.
Convenience alternative to @cpp QuadraticBezier<3, T> @ce. See
@ref QuadraticBezier and @ref Bezier for more information.
@see @ref QuadraticBezier2D, @ref Magnum::QuadraticBezier3D,
@ref Magnum::QuadraticBezier3Dd
*/
@ -217,8 +217,8 @@ template<class T> using QuadraticBezier3D = QuadraticBezier<3, T>;
/**
@brief Cubic Bézier curve
Convenience alternative to `Bezier<3, dimensions, T>`. See @ref Bezier for more
information.
Convenience alternative to @cpp Bezier<3, dimensions, T> @ce. See @ref Bezier
for more information.
@see @ref CubicBezier2D, @ref CubicBezier3D
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */
@ -228,8 +228,8 @@ template<UnsignedInt dimensions, class T> using CubicBezier = Bezier<3, dimensio
/**
@brief Two-dimensional cubic Bézier curve
Convenience alternative to `CubicBezier<2, T>`. See @ref CubicBezier
and @ref Bezier for more information.
Convenience alternative to @cpp CubicBezier<2, T> @ce. See @ref CubicBezier and
@ref Bezier for more information.
@see @ref CubicBezier3D, @ref Magnum::CubicBezier2D,
@ref Magnum::CubicBezier2Dd
*/
@ -240,8 +240,8 @@ template<class T> using CubicBezier2D = CubicBezier<2, T>;
/**
@brief Three-dimensional cubic Bézier curve
Convenience alternative to `CubicBezier<3, T>`. See @ref CubicBezier
and @ref Bezier for more information.
Convenience alternative to @cpp CubicBezier<3, T> @ce. See @ref CubicBezier and
@ref Bezier for more information.
@see @ref CubicBezier2D, @ref Magnum::CubicBezier3D,
@ref Magnum::CubicBezier3Dd
*/

8
src/Magnum/Math/BoolVector.h

@ -58,10 +58,10 @@ namespace Implementation {
@brief Vector storing boolean values
@tparam size Bit count
Result of component-wise comparison from Vector. The boolean values are stored
as bits in array of unsigned bytes, unused bits have undefined value which
doesn't affect comparison or @ref all() / @ref none() / @ref any() functions.
See also @ref matrix-vector for brief introduction.
Result of component-wise comparison from @ref Vector. The boolean values are
stored as bits in array of unsigned bytes, unused bits have undefined value
which doesn't affect comparison or @ref all() / @ref none() / @ref any()
functions. See also @ref matrix-vector for brief introduction.
*/
template<std::size_t size> class BoolVector {
static_assert(size != 0, "BoolVector cannot have zero elements");

139
src/Magnum/Math/Color.h

@ -211,15 +211,16 @@ template<class T> constexpr typename std::enable_if<std::is_integral<T>::value,
The class can store either floating-point (normalized) or integral
(denormalized) representation of linear RGB color. Colors in sRGB color space
should not be used directly in calculations -- they should be converted to
should not be used directly in calculations --- they should be converted to
linear RGB using @ref fromSrgb(), calculation done on the linear representation
and then converted back to sRGB using @ref toSrgb().
Note that constructor conversion between different types (like in @ref Vector
classes) doesn't do any (de)normalization, you should use @ref pack) and
@ref unpack() instead, for example:
@code
Color3 a(1.0f, 0.5f, 0.75f);
@code{.cpp}
Color3 a{1.0f, 0.5f, 0.75f};
auto b = pack<Color3ub>(a); // b == {255, 127, 191}
@endcode
@ -238,8 +239,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Red color
*
* Convenience alternative to e.g. `Color3(red, 0.0f, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::xAxis().
* Convenience alternative to e.g. @cpp Color3{red, 0.0f, 0.0f} @ce.
* With floating-point underlying type equivalent to @ref Vector3::xAxis().
* @see @ref green(), @ref blue(), @ref cyan()
*/
constexpr static Color3<T> red(T red = Implementation::fullChannel<T>()) {
@ -249,8 +250,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Green color
*
* Convenience alternative to e.g. `Color3(0.0f, green, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::yAxis().
* Convenience alternative to e.g. @cpp Color3(0.0f, green, 0.0f) @ce.
* With floating-point underlying type equivalent to @ref Vector3::yAxis().
* @see @ref red(), @ref blue(), @ref magenta()
*/
constexpr static Color3<T> green(T green = Implementation::fullChannel<T>()) {
@ -260,8 +261,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Blue color
*
* Convenience alternative to e.g. `Color3(0.0f, 0.0f, blue)`. With
* floating-point underlying type equivalent to @ref Vector3::zAxis().
* Convenience alternative to e.g. @cpp Color3{0.0f, 0.0f, blue} @ce.
* With floating-point underlying type equivalent to @ref Vector3::zAxis().
* @see @ref red(), @ref green(), @ref yellow()
*/
constexpr static Color3<T> blue(T blue = Implementation::fullChannel<T>()) {
@ -271,8 +272,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Cyan color
*
* Convenience alternative to e.g. `Color3(red, 1.0f, 1.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::xScale().
* Convenience alternative to e.g. @cpp Color3{red, 1.0f, 1.0f} @ce.
* With floating-point underlying type equivalent to @ref Vector3::xScale().
* @see @ref magenta(), @ref yellow(), @ref red()
*/
constexpr static Color3<T> cyan(T red = T(0)) {
@ -282,8 +283,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Magenta color
*
* Convenience alternative to e.g. `Color3(0.0f, green, 0.0f)`. With
* floating-point underlying type equivalent to @ref Vector3::yScale().
* Convenience alternative to e.g. @cpp Color3{1.0f, green, 1.0f} @ce.
* With floating-point underlying type equivalent to @ref Vector3::yScale().
* @see @ref cyan(), @ref yellow(), @ref green()
*/
constexpr static Color3<T> magenta(T green = T(0)) {
@ -293,8 +294,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Yellow color
*
* Convenience alternative to `Color3(0.0f, 0.0f, yellow)`. With
* floating-point underlying type equivalent to @ref Vector3::zScale().
* Convenience alternative to e.g. @cpp Color3{1.0f, 1.0f, yellow} @ce.
* With floating-point underlying type equivalent to @ref Vector3::zScale().
* @see @ref cyan(), @ref magenta(), @ref red()
*/
constexpr static Color3<T> yellow(T blue = T(0)) {
@ -311,8 +312,8 @@ template<class T> class Color3: public Vector3<T> {
/**
* @brief Type for storing HSV color space values
*
* Hue in range @f$ [0.0, 360.0] @f$, saturation and value in
* range @f$ [0.0, 1.0] @f$.
* Hue in range @f$ [0.0, 360.0] @f$, saturation and value in range
* @f$ [0.0, 1.0] @f$.
*/
typedef std::tuple<Deg<FloatingPointType>, FloatingPointType, FloatingPointType> Hsv;
@ -381,7 +382,8 @@ template<class T> class Color3: public Vector3<T> {
* Useful in cases where you have for example an 8-bit sRGB
* representation and want to create a floating-point linear RGB color
* out of it:
* @code
*
* @code{.cpp}
* Math::Vector3<UnsignedByte> srgb;
* auto rgb = Color3::fromSrgb(srgb);
* @endcode
@ -472,7 +474,8 @@ template<class T> class Color3: public Vector3<T> {
* @brief Convert to HSV representation
*
* Example usage:
* @code
*
* @code{.cpp}
* Deg hue;
* Float saturation, value;
* std::tie(hue, saturation, value) = color.toHsv();
@ -543,7 +546,8 @@ template<class T> class Color3: public Vector3<T> {
*
* Useful in cases where you have a floating-point linear RGB color and
* want to create for example an 8-bit sRGB representation out of it:
* @code
*
* @code{.cpp}
* Color3 color;
* Math::Vector3<UnsignedByte> srgb = color.toSrgb<UnsignedByte>();
* @endcode
@ -616,7 +620,7 @@ class Color4: public Vector4<T> {
/**
* @brief Red color
*
* Convenience alternative to e.g. `Color4(red, 0.0f, 0.0f, alpha)`.
* Convenience alternative to e.g. @cpp Color4{red, 0.0f, 0.0f, alpha} @ce.
* @see @ref green(), @ref blue(), @ref cyan()
*/
constexpr static Color4<T> red(T red = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
@ -626,7 +630,7 @@ class Color4: public Vector4<T> {
/**
* @brief Green color
*
* Convenience alternative to e.g. `Color4(0.0f, green, 0.0f, alpha)`.
* Convenience alternative to e.g. @cpp Color4{0.0f, green, 0.0f, alpha} @ce.
* @see @ref red(), @ref blue(), @ref magenta()
*/
constexpr static Color4<T> green(T green = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
@ -636,7 +640,7 @@ class Color4: public Vector4<T> {
/**
* @brief Blue color
*
* Convenience alternative to e.g. `Color4(0.0f, 0.0f, blue, alpha)`.
* Convenience alternative to e.g. @cpp Color4{0.0f, 0.0f, blue, alpha} @ce.
* @see @ref red(), @ref green(), @ref yellow()
*/
constexpr static Color4<T> blue(T blue = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) {
@ -646,7 +650,7 @@ class Color4: public Vector4<T> {
/**
* @brief Cyan color
*
* Convenience alternative to e.g. `Color4(red, 1.0f, 1.0f, alpha)`.
* Convenience alternative to e.g. @cpp Color4{red, 1.0f, 1.0f, alpha} @ce.
* @see @ref magenta(), @ref yellow(), @ref red()
*/
constexpr static Color4<T> cyan(T red = T(0), T alpha = Implementation::fullChannel<T>()) {
@ -656,7 +660,7 @@ class Color4: public Vector4<T> {
/**
* @brief Magenta color
*
* Convenience alternative to e.g. `Color4(1.0f, green, 1.0f, alpha)`.
* Convenience alternative to e.g. @cpp Color4{1.0f, green, 1.0f, alpha} @ce.
* @see @ref cyan(), @ref yellow(), @ref green()
*/
constexpr static Color4<T> magenta(T green = T(0), T alpha = Implementation::fullChannel<T>()) {
@ -666,7 +670,7 @@ class Color4: public Vector4<T> {
/**
* @brief Yellow color
*
* Convenience alternative to e.g. `Color4(1.0f, 1.0f, blue, alpha)`.
* Convenience alternative to e.g. @cpp Color4{1.0f, 1.0f, blue, alpha} @ce.
* @see @ref cyan(), @ref magenta(), @ref red()
*/
constexpr static Color4<T> yellow(T blue = T(0), T alpha = Implementation::fullChannel<T>()) {
@ -676,8 +680,9 @@ class Color4: public Vector4<T> {
/**
* @brief Create RGB color from HSV representation
* @param hsv Color in HSV color space
* @param a Alpha value, defaults to `1.0` for floating-point types
* and maximum positive value for integral types.
* @param a Alpha value, defaults to @cpp 1.0 @ce for
* floating-point types and maximum positive value for integral
* types
*
* Hue can overflow the range @f$ [0.0, 360.0] @f$.
* @see @ref toHsv()
@ -724,8 +729,9 @@ class Color4: public Vector4<T> {
/**
* @brief Create linear RGBA color from sRGB representation
* @param srgb Color in sRGB color space
* @param a Alpha value, defaults to `1.0` for floating-point
* types and maximum positive value for integral types.
* @param a Alpha value, defaults to @cpp 1.0 @ce for
* floating-point types and maximum positive value for integral
* types
*
* Applies inverse sRGB curve onto RGB channels of the input. Alpha
* value is taken as-is. See @ref Color3::fromSrgb() for more
@ -745,7 +751,8 @@ class Color4: public Vector4<T> {
* Useful in cases where you have for example an 8-bit sRGB + alpha
* representation and want to create a floating-point linear RGBA color
* out of it:
* @code
*
* @code{.cpp}
* Math::Vector4<UnsignedByte> srgbAlpha;
* auto rgba = Color4::fromSrgbAlpha(srgbAlpha);
* @endcode
@ -759,13 +766,15 @@ class Color4: public Vector4<T> {
/** @overload
* @brief Create linear RGB color from integral sRGB representation
* @param srgb Color in sRGB color space
* @param a Alpha value, defaults to `1.0` for floating-point
* types and maximum positive value for integral types.
* @param a Alpha value, defaults to @cpp 1.0 @ce for
* floating-point types and maximum positive value for integral
* types
*
* Useful in cases where you have for example an 8-bit sRGB
* representation and want to create a floating-point linear RGBA color
* out of it:
* @code
*
* @code{.cpp}
* Math::Vector3<UnsignedByte> srgb;
* auto rgba = Color4::fromSrgb(srgb);
* @endcode
@ -779,8 +788,9 @@ class Color4: public Vector4<T> {
/**
* @brief Create RGBA color from CIE XYZ representation
* @param xyz Color in CIE XYZ color space
* @param a Alpha value, defaults to `1.0` for floating-point types
* and maximum positive value for integral types.
* @param a Alpha value, defaults to @cpp 1.0 @ce for
* floating-point types and maximum positive value for integral
* types
*
* Applies transformation matrix, returning the input in linear RGB
* color space. See @ref Color3::fromXyz() for more information.
@ -815,8 +825,9 @@ class Color4: public Vector4<T> {
/**
* @copydoc Color3::Color3(T)
* @param alpha Alpha value, defaults to `1.0` for floating-point types
* and maximum positive value for integral types.
* @param alpha Alpha value, defaults to @cpp 1.0 @ce for
* floating-point types and maximum positive value for integral
* types
*/
constexpr explicit Color4(T rgb, T alpha = Implementation::fullChannel<T>()) noexcept: Vector4<T>(rgb, rgb, rgb, alpha) {}
@ -825,8 +836,8 @@ class Color4: public Vector4<T> {
* @param r R value
* @param g G value
* @param b B value
* @param a A value, defaults to `1.0` for floating-point types and
* maximum positive value for integral types.
* @param a A value, defaults to @cpp 1.0 @ce for floating-point
* types and maximum positive value for integral types.
*/
constexpr /*implicit*/ Color4(T r, T g, T b, T a = Implementation::fullChannel<T>()) noexcept: Vector4<T>(r, g, b, a) {}
@ -866,7 +877,8 @@ class Color4: public Vector4<T> {
*
* The alpha channel is not subject to any conversion, so it is
* ignored. Example usage:
* @code
*
* @code{.cpp}
* Deg hue;
* Float saturation, value;
* std::tie(hue, saturation, value) = color.toHsv();
@ -920,7 +932,8 @@ class Color4: public Vector4<T> {
* Useful in cases where you have a floating-point linear RGBA color
* and want to create for example an 8-bit sRGB + alpha representation
* out of it:
* @code
*
* @code{.cpp}
* Color4 color;
* Math::Vector4<UnsignedByte> srgbAlpha = color.toSrgbAlpha<UnsignedByte>();
* @endcode
@ -998,7 +1011,8 @@ namespace Literals {
@brief 8bit-per-channel linear RGB literal
Unpacks the literal into three 8-bit values. Example usage:
@code
@code{.cpp}
Color3ub a = 0x33b27f_rgb; // {0x33, 0xb2, 0x7f}
@endcode
@ -1020,13 +1034,14 @@ Unpacks the literal into three 8-bit values without any colorspace conversion.
Behaves identically to @link operator""_rgb() @endlink though it doesn't
return a @ref Color3 type to indicate that the resulting value is not linear
RGB. Use this literal to document that given value is in sRGB. Example usage:
@code
@code{.cpp}
Math::Vector3<UnsignedByte> a = 0x33b27f_srgb; // {0x33, 0xb2, 0x7f}
@endcode
@attention Note that colors in sRGB representation should not be used directly
in calculations -- they should be converted to linear RGB, calculation done
on the linear representation and then converted back to sRGB. Use the
in calculations --- they should be converted to linear RGB, calculation
done on the linear representation and then converted back to sRGB. Use the
@link operator""_srgbf() @endlink literal if you want to get a linear RGB
representation directly or convert the value using @ref Color3::fromSrgb().
@ -1042,7 +1057,8 @@ constexpr Vector3<UnsignedByte> operator "" _srgb(unsigned long long value) {
@brief 8bit-per-channel linear RGBA literal
Unpacks the literal into four 8-bit values. Example usage:
@code
@code{.cpp}
Color4ub a = 0x33b27fcc_rgba; // {0x33, 0xb2, 0x7f, 0xcc}
@endcode
@ -1065,13 +1081,14 @@ Behaves identically to @link operator""_rgba() @endlink though it doesn't
return a @ref Color4 type to indicate that the resulting value is not linear
RGBA. Use this literal to document that given value is in sRGB + alpha. Example
usage:
@code
@code{.cpp}
Math::Vector4<UnsignedByte> a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc}
@endcode
@attention Note that colors in sRGB representation should not be used directly
in calculations -- they should be converted to linear RGB, calculation done
on the linear representation and then converted back to sRGB. Use the
in calculations --- they should be converted to linear RGB, calculation
done on the linear representation and then converted back to sRGB. Use the
@link operator""_srgbaf() @endlink literal if you want to get a linear RGBA
representation directly or convert the value using @ref Color4::fromSrgbAlpha().
@ -1087,7 +1104,8 @@ constexpr Vector4<UnsignedByte> operator "" _srgba(unsigned long long value) {
@brief Float linear RGB literal
Unpacks the 8-bit values into three floats. Example usage:
@code
@code{.cpp}
Color3 a = 0x33b27f_rgbf; // {0.2f, 0.698039f, 0.498039f}
@endcode
@ -1108,9 +1126,11 @@ inline Color3<Float> operator "" _rgbf(unsigned long long value) {
Unpacks the 8-bit values into three floats and converts the color space from
sRGB to linear RGB. See @ref Color3::fromSrgb() for more information. Example
usage:
@code
@code{.cpp}
Color3 a = 0x33b27f_srgbf; // {0.0331048f, 0.445201f, 0.212231f}
@endcode
@see @link operator""_srgbaf() @endlink, @link operator""_srgb() @endlink,
@link operator""_rgbf() @endlink
*/
@ -1122,7 +1142,8 @@ inline Color3<Float> operator "" _srgbf(unsigned long long value) {
@brief Float linear RGBA literal
Unpacks the 8-bit values into four floats. Example usage:
@code
@code{.cpp}
Color4 a = 0x33b27fcc_rgbaf; // {0.2f, 0.698039f, 0.498039f, 0.8f}
@endcode
@ -1143,9 +1164,11 @@ inline Color4<Float> operator "" _rgbaf(unsigned long long value) {
Unpacks the 8-bit values into four floats and converts the color space from
sRGB + alpha to linear RGBA. See @ref Color4::fromSrgbAlpha() for more
information. Example usage:
@code
@code{.cpp}
Color4 a = 0x33b27fcc_srgbaf; // {0.0331048f, 0.445201f, 0.212231f, 0.8f}
@endcode
@see @link operator""_srgbf() @endlink, @link operator""_srgba() @endlink,
@link operator""_rgbaf() @endlink
*/
@ -1158,16 +1181,16 @@ inline Color4<Float> operator "" _srgbaf(unsigned long long value) {
/**
@debugoperator{Magnum::Math::Color3}
Prints the value as hex color (e.g. `#ff33aa`). Other underlying types are
handled by @ref operator<<(Corrade::Utility::Debug&, const Vector<size, T>&).
Prints the value as hex color (e.g. @cb{.shell-session} #ff33aa @ce). Other
underlying types are handled by @ref operator<<(Corrade::Utility::Debug&, const Vector<size, T>&).
*/
MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, const Color3<UnsignedByte>& value);
/**
@debugoperator{Magnum::Math::Color4}
Prints the value as hex color (e.g. `#9933aaff`). Other underlying types are
handled by @ref operator<<(Corrade::Utility::Debug&, const Vector<size, T>&).
Prints the value as hex color (e.g. @cb{.shell-session} #9933aaff @ce). Other
underlying types are handled by @ref operator<<(Corrade::Utility::Debug&, const Vector<size, T>&).
*/
MAGNUM_EXPORT Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, const Color4<UnsignedByte>& value);

3
src/Magnum/Math/Dual.h

@ -98,7 +98,8 @@ template<class T> class Dual {
*
* Performs only default casting on the values, no rounding or anything
* else. Example usage:
* @code
*
* @code{.cpp}
* Dual<Float> floatingPoint(1.3f, 2.7f);
* Dual<Byte> integral(floatingPoint);
* // integral == {1, 2}

14
src/Magnum/Math/DualComplex.h

@ -271,7 +271,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
/**
* @brief Complex number length squared
*
* Should be used instead of length() for comparing complex number
* Should be used instead of @ref length() for comparing complex number
* length with other values, because it doesn't compute the square root. @f[
* |\hat c|^2 = c_0 \cdot c_0 = |c_0|^2
* @f]
@ -284,8 +284,8 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
/**
* @brief Dual quaternion length
*
* See lengthSquared() which is faster for comparing length with other
* values. @f[
* See @ref lengthSquared() which is faster for comparing length with
* other values. @f[
* |\hat c| = \sqrt{c_0 \cdot c_0} = |c_0|
* @f]
* @todo can this be done similarly to dual quaternions?
@ -310,8 +310,8 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
/**
* @brief Inverted dual complex number
*
* See invertedNormalized() which is faster for normalized dual complex
* numbers. @f[
* See @ref invertedNormalized() which is faster for normalized dual
* complex numbers. @f[
* \hat c^{-1} = c_0^{-1} - \epsilon c_\epsilon
* @f]
* @todo can this be done similarly to dual quaternions?
@ -336,8 +336,8 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
/**
* @brief Rotate and translate point with dual complex number
*
* See transformPointNormalized(), which is faster for normalized dual
* complex number. @f[
* See @ref transformPointNormalized(), which is faster for normalized
* dual complex number. @f[
* v' = \hat c v = \hat c ((0 + i) + \epsilon(v_x + iv_y))
* @f]
* @see @ref DualComplex(const Vector2<T>&), @ref dual(),

15
src/Magnum/Math/Functions.h

@ -93,12 +93,15 @@ template<class T> T exp(T exponent) { return std::exp(exponent); }
@brief Integer division with remainder
Example usage:
@code
@code{.cpp}
Int quotient, remainder;
std::tie(quotient, remainder) = Math::div(57, 6); // {9, 3}
@endcode
Equivalent to the following, but possibly done in a single CPU instruction:
@code
@code{.cpp}
Int quotient = 57/6;
Int remainder = 57%6;
@endcode
@ -370,9 +373,11 @@ template<class T> inline std::pair<T, T> minmax(std::initializer_list<T> list) {
Values smaller than @p min are set to @p min, values larger than @p max are
set to @p max. Equivalent to:
@code
@code{.cpp}
Math::min(Math::max(value, min), max)
@endcode
<em>NaN</em>s passed in @p value parameter are propagated.
@see @ref min(), @ref max()
*/
@ -546,9 +551,7 @@ template<std::size_t size, class T, class U> inline typename std::enable_if<!Imp
}
#endif
/**
@overload
/** @overload
Similar to the above, but instead of multiplication and addition it just does
component-wise selection from either @p a or @p b based on values in @p t.
*/

6
src/Magnum/Math/Half.h

@ -48,7 +48,8 @@ equality comparison with correct treatment of NaN values, promotion and
negation operator, an @link Literals::operator""_h() operator""_h() @endlink
literal and an @ref operator<<(Debug&, Half) debug operator. Internally the class uses
@ref packHalf() and @ref unpackHalf(). Example usage:
@code
@code{.cpp}
using namespace Math::Literals;
Half a = 3.14159_h;
@ -60,7 +61,8 @@ Debug{} << UnsignedShort(a); // Prints 25675
Note that it is also possible to use this type inside @ref Vector classes,
though, again, only for passing data around and converting them, without any
arithmetic operations:
@code
@code{.cpp}
Math::Vector3<Half> a{3.14159_h, -1.4142_h, 1.618_h};
Vector3 b{a}; // converts to 32-bit floats
Debug{} << a; // prints {3.14159, -1.4142, 1.618}

3
src/Magnum/Math/Matrix.h

@ -122,7 +122,8 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
*
* @code{.cpp}
* Matrix2x2<Float> floatingPoint({1.3f, 2.7f},
* {-15.0f, 7.0f});
* Matrix2x2<Byte> integral(floatingPoint);

4
src/Magnum/Math/Matrix3.h

@ -110,8 +110,8 @@ template<class T> class Matrix3: public Matrix3x3<T> {
*
* Expects that the normal is normalized. Reflection along axes can be
* done in a slightly simpler way also using @ref scaling(), e.g.
* `Matrix3::reflection(Vector2::yAxis())` is equivalent to
* `Matrix3::scaling(Vector2::yScale(-1.0f))`. @f[
* @cpp Matrix3::reflection(Vector2::yAxis()) @ce is equivalent to
* @cpp Matrix3::scaling(Vector2::yScale(-1.0f)) @ce. @f[
* \boldsymbol{A} = \boldsymbol{I} - 2 \boldsymbol{NN}^T ~~~~~ \boldsymbol{N} = \begin{pmatrix} n_x \\ n_y \end{pmatrix}
* @f]
* @see @ref Matrix4::reflection(), @ref Vector::isNormalized()

12
src/Magnum/Math/Matrix4.h

@ -124,7 +124,7 @@ template<class T> class Matrix4: public Matrix4x4<T> {
* @brief 3D rotation matrix around X axis
* @param angle Rotation angle (counterclockwise)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::xAxis())`. @f[
* Faster than calling @cpp Matrix4::rotation(angle, Vector3::xAxis()) @ce. @f[
* \boldsymbol{A} = \begin{pmatrix}
* 1 & 0 & 0 & 0 \\
* 0 & \cos\theta & -\sin\theta & 0 \\
@ -142,7 +142,7 @@ template<class T> class Matrix4: public Matrix4x4<T> {
* @brief 3D rotation matrix around Y axis
* @param angle Rotation angle (counterclockwise)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::yAxis())`. @f[
* Faster than calling @cpp Matrix4::rotation(angle, Vector3::yAxis()) @ce. @f[
* \boldsymbol{A} = \begin{pmatrix}
* \cos\theta & 0 & \sin\theta & 0 \\
* 0 & 1 & 0 & 0 \\
@ -160,7 +160,7 @@ template<class T> class Matrix4: public Matrix4x4<T> {
* @brief 3D rotation matrix around Z axis
* @param angle Rotation angle (counterclockwise)
*
* Faster than calling `Matrix4::rotation(angle, Vector3::zAxis())`. @f[
* Faster than calling @cpp Matrix4::rotation(angle, Vector3::zAxis()) @ce. @f[
* \boldsymbol{A} = \begin{pmatrix}
* \cos\theta & -\sin\theta & 0 & 0 \\
* \sin\theta & \cos\theta & 0 & 0 \\
@ -180,8 +180,8 @@ template<class T> class Matrix4: public Matrix4x4<T> {
*
* Expects that the normal is normalized. Reflection along axes can be
* done in a slightly simpler way also using @ref scaling(), e.g.
* `Matrix4::reflection(Vector3::yAxis())` is equivalent to
* `Matrix4::scaling(Vector3::yScale(-1.0f))`. @f[
* @cpp Matrix4::reflection(Vector3::yAxis()) @ce is equivalent to
* @cpp Matrix4::scaling(Vector3::yScale(-1.0f)) @ce. @f[
* \boldsymbol{A} = \boldsymbol{I} - 2 \boldsymbol{NN}^T ~~~~~ \boldsymbol{N} = \begin{pmatrix} n_x \\ n_y \\ n_z \end{pmatrix}
* @f]
* @see @ref Matrix3::reflection(), @ref Vector::isNormalized()
@ -340,7 +340,7 @@ template<class T> class Matrix4: public Matrix4x4<T> {
* @param eye Location to place the matrix
* @param target Location towards which the matrix is oriented
* @param up Vector as a guide of which way is up (should not be
* the same direction as `target - eye`)
* the same direction as @cpp target - eye @ce)
*
* @attention This function transforms an object so it's at @p eye
* position and oriented towards @p target, it does *not* produce

27
src/Magnum/Math/Packing.h

@ -53,16 +53,17 @@ value in range @f$ [0, 1] @f$ or from *signed* integral to range @f$ [-1, 1] @f$
@ref Magnum::Short "Short", @ref Magnum::Double "Double" from
@ref Magnum::Int "Int" and similarly for vector types).
@attention To ensure the integral type is correctly detected when using
literals, this function should be called with both template parameters
explicit, e.g.:
@code
// Literal type is (signed) char, but we assumed unsigned char, a != 1.0f
Float a = Math::unpack<Float>('\xFF');
// b = 1.0f
Float b = Math::unpack<Float, UnsignedByte>('\xFF');
@endcode
@attention
To ensure the integral type is correctly detected when using literals, this
function should be called with both template parameters explicit, e.g.:
@attention
@code{.cpp}
// Literal type is (signed) char, but we assumed unsigned char, a != 1.0f
Float a = Math::unpack<Float>('\xFF');
// b = 1.0f
Float b = Math::unpack<Float, UnsignedByte>('\xFF');
@endcode
@see @ref pack()
*/
@ -73,7 +74,8 @@ template<class FloatingPoint, class Integral> inline FloatingPoint unpack(const
Alternative to the above with ability to specify how many bits of the integral
representation to use. Example usage:
@code
@code{.cpp}
Float a = Math::unpack<Float, UnsignedShort>(8191); // 0.124987f
Float b = Math::unpack<Float, UnsignedShort, 14>(8191); // 0.499969f
Float b = Math::unpack<Float, 14>(8191u); // 0.499969f
@ -170,7 +172,8 @@ template<class Integral, std::size_t size, class FloatingPoint, UnsignedInt bits
Alternative to the above with ability to specify how many bits of the integral
representation to use. Example usage:
@code
@code{.cpp}
auto a = Math::pack<UnsignedShort>(0.5f); // 32767
auto b = Math::pack<UnsignedShort, 14>(0.5f); // 8191
@endcode

5
src/Magnum/Math/Range.h

@ -89,7 +89,8 @@ template<UnsignedInt dimensions, class T> class Range {
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
*
* @code{.cpp}
* Range2D<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f});
* Range2D<Byte> integral(floatingPoint); // {{1, 2}, {-15, 7}}
* @endcode
@ -215,7 +216,7 @@ template<UnsignedInt dimensions, class T> class Range {
/**
@brief One-dimensional range
Convenience alternative to `Range<1, T>`. See @ref Range for more
Convenience alternative to @cpp Range<1, T> @ce. See @ref Range for more
information.
*/
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Multiple definitions still broken */

18
src/Magnum/Math/RectangularMatrix.h

@ -141,7 +141,8 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
*
* @code{.cpp}
* RectangularMatrix<4, 1, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
* RectangularMatrix<4, 1, Byte> integral(floatingPoint);
* // integral == {1, 2, -15, 7}
@ -175,7 +176,8 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
*
* Particular elements can be accessed using @ref Vector::operator[](),
* e.g.:
* @code
*
* @code{.cpp}
* RectangularMatrix<4, 3, Float> m;
* Float a = m[2][1];
* @endcode
@ -469,7 +471,7 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
/**
@brief Matrix with 2 columns and 3 rows
Convenience alternative to `RectangularMatrix<2, 3, T>`. See
Convenience alternative to @cpp RectangularMatrix<2, 3, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix2x3, @ref Magnum::Matrix2x3d
*/
@ -480,7 +482,7 @@ template<class T> using Matrix2x3 = RectangularMatrix<2, 3, T>;
/**
@brief Matrix with 3 columns and 2 rows
Convenience alternative to `RectangularMatrix<3, 2, T>`. See
Convenience alternative to @cpp RectangularMatrix<3, 2, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix3x2, @ref Magnum::Matrix3x2d
*/
@ -491,7 +493,7 @@ template<class T> using Matrix3x2 = RectangularMatrix<3, 2, T>;
/**
@brief Matrix with 2 columns and 4 rows
Convenience alternative to `RectangularMatrix<2, 4, T>`. See
Convenience alternative to @cpp RectangularMatrix<2, 4, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix2x4, @ref Magnum::Matrix2x4d
*/
@ -502,7 +504,7 @@ template<class T> using Matrix2x4 = RectangularMatrix<2, 4, T>;
/**
@brief Matrix with 4 columns and 2 rows
Convenience alternative to `RectangularMatrix<4, 2, T>`. See
Convenience alternative to @cpp RectangularMatrix<4, 2, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix4x2, @ref Magnum::Matrix4x2d
*/
@ -513,7 +515,7 @@ template<class T> using Matrix4x2 = RectangularMatrix<4, 2, T>;
/**
@brief Matrix with 3 columns and 4 rows
Convenience alternative to `RectangularMatrix<3, 4, T>`. See
Convenience alternative to @cpp RectangularMatrix<3, 4, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix3x4, @ref Magnum::Matrix3x4d
*/
@ -524,7 +526,7 @@ template<class T> using Matrix3x4 = RectangularMatrix<3, 4, T>;
/**
@brief Matrix with 4 columns and 3 rows
Convenience alternative to `RectangularMatrix<4, 3, T>`. See
Convenience alternative to @cpp RectangularMatrix<4, 3, T> @ce. See
@ref RectangularMatrix for more information.
@see @ref Magnum::Matrix4x3, @ref Magnum::Matrix4x3d
*/

15
src/Magnum/Math/Swizzle.h

@ -65,17 +65,20 @@ namespace Implementation {
@brief Swizzle Vector components
Creates new vector from given components. Example:
@code
@code{.cpp}
Vector4i original(-1, 2, 3, 4);
auto vec = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original);
// vec == { 4, 1, 0, -1, 2, 3 }
@endcode
You can use letters `x`, `y`, `z`, `w` and `r`, `g`, `b`, `a` for addressing
components or letters `0` and `1` for zero and one. Count of elements is
unlimited, but must be at least one. If the resulting vector is two, three or
four-component, corresponding @ref Math::Vector2, @ref Math::Vector3,
@ref Math::Vector4, @ref Color3 or @ref Color4 specialization is returned.
You can use letters @cpp 'x' @ce, @cpp 'y' @ce, @cpp 'z' @ce, @cpp 'w' @ce and
@cpp 'r' @ce, @cpp 'g' @ce, @cpp 'b' @ce, @cpp 'a' @ce for addressing
components or letters @cpp '0' @ce and @cpp '1' @ce for zero and one. Count of
elements is unlimited, but must be at least one. If the resulting vector is
two, three or four-component, corresponding @ref Vector2, @ref Vector3,
@ref Vector4, @ref Color3 or @ref Color4 specialization is returned.
@see @ref matrix-vector-component-access, @ref Vector4::xyz(),
@ref Vector4::rgb(), @ref Vector4::xy(), @ref Vector3::xy()

3
src/Magnum/Math/TypeTraits.h

@ -145,7 +145,8 @@ template<class T> struct TypeTraits: Implementation::TypeTraitsDefault<T> {
* comparing e.g. a calculated nearly-zero difference with zero, knowing
* the magnitude of original values so the epsilon can be properly scaled.
* In other words, the following lines are equivalent:
* @code
*
* @code{.cpp}
* Float a, b;
* Math::TypeTraits<Float>::equals(a, b);
* Math::TypeTraits<Float>::equalsZero(a - b, Math::max(Math::abs(a), Math::abs(b)));

13
src/Magnum/Math/Vector.h

@ -199,7 +199,8 @@ template<std::size_t size, class T> class Vector {
*
* Performs only default casting on the values, no rounding or
* anything else. Example usage:
* @code
*
* @code{.cpp}
* Vector<4, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
* Vector<4, Byte> integral(floatingPoint);
* // integral == {1, 2, -15, 7}
@ -496,9 +497,11 @@ template<std::size_t size, class T> class Vector {
* Convenience equivalent to the following code. Due to operation order
* this function is faster than the obvious way of sizing
* @ref normalized() vector.
* @code
* vec*(vec.lengthInverted()*length) // the brackets are important
*
* @code{.cpp}
* vec*(vec.lengthInverted()*length) // the parentheses are important
* @endcode
*
* @see @ref normalized()
*/
Vector<size, T> resized(T length) const {
@ -511,7 +514,7 @@ template<std::size_t size, class T> class Vector {
* Returns vector projected onto @p line. @f[
* \boldsymbol a_1 = \frac{\boldsymbol a \cdot \boldsymbol b}{\boldsymbol b \cdot \boldsymbol b} \boldsymbol b
* @f]
* @see @ref dot(), @ref projectedOntoNormalized()
* @see @ref Math::dot(), @ref projectedOntoNormalized()
*/
Vector<size, T> projected(const Vector<size, T>& line) const {
return line*Math::dot(*this, line)/line.dot();
@ -525,7 +528,7 @@ template<std::size_t size, class T> class Vector {
* \boldsymbol a_1 = \frac{\boldsymbol a \cdot \boldsymbol b}{\boldsymbol b \cdot \boldsymbol b} \boldsymbol b =
* (\boldsymbol a \cdot \boldsymbol b) \boldsymbol b
* @f]
* @see @ref dot() const
* @see @ref Math::dot()
*/
Vector<size, T> projectedOntoNormalized(const Vector<size, T>& line) const;

8
src/Magnum/Math/Vector2.h

@ -66,9 +66,11 @@ template<class T> class Vector2: public Vector<2, T> {
* @brief Vector in direction of X axis (right)
*
* Usable for translation in given axis, for example:
* @code
*
* @code{.cpp}
* Matrix3::translation(Vector2::xAxis(5.0f)); // same as Matrix3::translation({5.0f, 0.0f});
* @endcode
*
* @see @ref yAxis(), @ref xScale(), @ref Matrix3::right()
*/
constexpr static Vector2<T> xAxis(T length = T(1)) { return {length, T(0)}; }
@ -85,9 +87,11 @@ template<class T> class Vector2: public Vector<2, T> {
* @brief Scaling vector in direction of X axis (width)
*
* Usable for scaling along given direction, for example:
* @code
*
* @code{.cpp}
* Matrix3::scaling(Vector2::xScale(-2.0f)); // same as Matrix3::scaling({-2.0f, 1.0f});
* @endcode
*
* @see @ref yScale(), @ref xAxis()
*/
constexpr static Vector2<T> xScale(T scale) { return {scale, T(1)}; }

8
src/Magnum/Math/Vector3.h

@ -70,10 +70,12 @@ template<class T> class Vector3: public Vector<3, T> {
* @brief Vector in direction of X axis (right)
*
* Usable for translation or rotation along given axis, for example:
* @code
*
* @code{.cpp}
* Matrix4::translation(Vector3::xAxis(5.0f)); // same as Matrix4::translation({5.0f, 0.0f, 0.0f});
* Matrix4::rotation(30.0_degf, Vector3::xAxis()); // same as Matrix::rotation(30.0_degf, {1.0f, 0.0f, 0.0f});
* @endcode
*
* @see @ref yAxis(), @ref zAxis(), @ref xScale(), @ref Color3::red(),
* @ref Matrix4::right()
*/
@ -99,9 +101,11 @@ template<class T> class Vector3: public Vector<3, T> {
* @brief Scaling vector in direction of X axis (width)
*
* Usable for scaling along given direction, for example:
* @code
*
* @code{.cpp}
* Matrix4::scaling(Vector3::xScale(-2.0f)); // same as Matrix4::scaling({-2.0f, 1.0f, 1.0f});
* @endcode
*
* @see @ref yScale(), @ref zScale(), @ref Color3::cyan(), @ref xAxis()
*/
constexpr static Vector3<T> xScale(T scale) { return {scale, T(1), T(1)}; }

Loading…
Cancel
Save