Name already in use

栏目:影视资讯  时间:2022-10-29
手机版

  Release is 2.2-beta License is Unlicense Travis CI build status Appveyor build status

  is a single header, public domain, short vector math library for C++. It is inspired by the syntax of popular shading and compute languages and is intended to serve as a lightweight alternative to projects such as GLM, Boost.QVM or Eigen in domains such as computer graphics, computational geometry, and physical simulation. It allows you to easily write programs like the following:

  aims to be:

  Lightweight: The library is defined in a single header file which is less than a thousand lines of code. Dependency free: There are no dependencies beyond a compliant C++11 compiler and a small subset of the standard library. Standards compliant: Almost all operations are free of undefined behavior and can be evaluated in a context. Generic: All types and operations are parameterized over scalar type, and can be mixed within expressions. Type promotion rules roughly match the C standard. Consistent: Named functions and overloaded operators perform the same conceptual operation on all data types for which they are supported. Complete: There are very few restrictions on which operations may be applied to which data types. Easy to integrate: The library defines no symbols in the public namespace, and provides a mechanism for defining implicit conversions to external or user-provided data types. The documentation for is still in progress.

  Data structures Vectors Matrices Function listing Vector algebra Quaternion algebra Matrix algebra Component-wise operations Reductions Optional features Type aliases overloads User-defined conversions Higher order functions Changes from v2.1 Vectors defines a fixed-length vector containing exactly elements of type . Convenience aliases such as , , or are provided in the namespace. This data structure can be used to store a wide variety of types of data, including geometric vectors, points, homogeneous coordinates, plane equations, colors, texture coordinates, or any other situation where you need to manipulate a small sequence of numbers. As such, is supported by a set of algebraic and component-wise functions, as well as a set of standard reductions.

  :

  is : is constructible from elements of type : is and : is and : is explicitly constructible from a single element of type : is explicitly constructible from a of some other type : has fields : supports indexing: supports unary operators , , and in component-wise fashion: supports binary operators , , , , , , , , and in component-wise fashion: supports binary operators with a scalar on the left or the right: supports operators , , , , , , , , and with vectors or scalars on the right: supports operations on mixed element types: supports range-based for: has a flat memory layout: Matrices defines a fixed-size matrix containing exactly rows and columns of type , in column-major order. Convenience aliases such as or are provided in the namespace. This data structure is supported by a set of algebraic functions and component-wise functions, as well as a set of standard reductions.

  :

  is :

  is constructible from columns of type :

  is constructible from :

  is and :

  is and :

  is explicitly constructible from a single element of type :

  is explicitly constructible from a of some other type :

  supports indexing into columns:

  supports retrieval (but not assignment) of rows:

  supports unary operators , , and in component-wise fashion:

  supports binary operators , , , , , , , , and in component-wise fashion:

  supports binary operators with a scalar on the left or the right:

  supports operators , , , , , , , , and with matrices or scalars on the right:

  supports operations on mixed element types:

  supports range-based for over columns

  has a flat memory layout

  Vector algebra is the cross or vector product of vectors and

  is shorthand for is shorthand for is shorthand for is the dot or inner product of vectors and

  is the length or magnitude of a vector

  is the square of the length or magnitude of vector

  is a unit length vector in the same direction as (undefined for zero-length vectors)

  is the Euclidean distance between points and

  is the square of the Euclidean distance between points and

  is the angle in radians between vectors and

  is the angle in radians between unit vectors and (undefined for non-unit vectors)

  is the vector rotated counter-clockwise by the angle in radians

  is shorthand for

  is the spherical linear interpolation between unit vectors and (undefined for non-unit vectors) by parameter

  Quaternion algebra A small set of functions provides support for quaternion math, using values to represent quaternions of the form .

  is the Hamilton product of quaternions and

  is the conjugate of quaternion

  is the inverse or reciprocal of quaternion (undefined for zero-length quaternions)

  is the exponential of quaternion

  is the logarithm of quaternion

  is the quaternion raised to the exponent

  A second set of functions provides support for using unit-length quaternions to represent 3D spatial rotations. Their results are undefined for quaternions which are not of unit-length.

  is the angle in radians of the rotation expressed by quaternion

  is the axis of rotation expression by quaternion (undefined for zero-angle quaternions)

  is vector rotated via rotation quaternion

  is a 3x3 rotation matrix which performs the same operation as rotation quaternion

  is (efficient) shorthand for

  is (efficient) shorthand for

  is (efficient) shorthand for

  It is possible to use the and functions to interpolate rotation quaternions as though they were simply four-dimensional vectors. However, the rotation quaternions form a double cover over spatial rotations in three dimensions. This means that there are two distinct rotation quaternions representing each spatial rotation. Naively interpolating between two spatial rotations using quaternions could follow the "short path" or the "long path" between these rotations, depending on which specific quaternions are being interpolated.

  is similar to , but always chooses the "short path" between the rotations represented by and . is similar to , but always chooses the "short path" between the rotations represented by and . Matrix algebra is the matrix product of matrices and ** is the matrix product of matrix and a column matrix containing the elements of vector ** is shorthand for

  is the outer product of vectors and

  is a vector containing the elements along the main diagonal of matrix

  is the sum of the elements along the main diagonal of matrix

  is the transpose of matrix

  is the adjugate or classical adjoint of matrix (the transpose of its cofactor matrix, or the numerator in the expression of its inverse)

  is the comatrix or cofactor matrix of matrix (the transpose of its adjugate matrix)

  is the determinant of matrix

  is the multiplicative inverse of the invertible matrix (undefined for singular inputs)

  Component-wise operations The unary functions , , , , , , , , , , , , , , , , accept a vector-valued argument and produce a vector-valued result by passing individual elements to the function of the same name in the namespace, as defined by or .

  The binary functions , , , and function similarly, except that either argument can be a vector or a scalar.

  The binary functions , , , , , and apply operators , , , , and respectively in a component-wise fashion, returning a . As before, either argument can be a vector or a scalar.

  performs the component-wise selection of lesser elements, as by . Either argument can be a vector or a scalar.

  performs the component-wise selection of greater elements, as by . Either argument can be a vector or a scalar.

  performs the component-wise clamping of elements between a low and high boundary, as by . Any argument can be a vector or a scalar.

  performs a component-wise ternary operator, as by . Any argument can be a vector or a scalar.

  performs a component-wise linear interpolation, as by . Any argument can be a vector or a scalar.

  Reductions is if any element of the vector is is if all elements of the vector are is the sum of all elements in the vector returns the product of all elements in the vector returns the value of the least element in the vector returns the value of the greatest element in the vector returns the zero-based index of the least element in the vector returns the zero-based index of the greatest element in the vector Comparisons is conceptually equivalent to from C++20. It compares two values of equivalent shape and returns a value which supports all six standard comparisons against . It provides the same ordering guarantees as the underlying scalar type. That is, a provides a strong ordering, where a provides a partial odering.

  Type aliases By default, does not define any symbols in the global namespace, and a three-element vector of single-precision floating point values must be spelled . In various libraries and shading languages, such a type might be spelled , , , , , or any one of a hundred other possibilities. provides a collection of useful aliases in the namespace. If the names specified in this namespace are suitable for a user's purposes, they can quickly be brought into scope as follows:

  Note that this only brings the type aliases into global scope. The core types and all functions and operator overloads defined by the library remain in .

  If the spellings in conflict with other types that have been defined in the global namespace or in other namespaces of interest, the user can choose to omit the directive and instead define their own aliases as desired.

  It is, of course, always possible to use the core types directly if operating in an environment where no additional symbols should be defined.

  The set of type aliases defined in is as follows:

  aliased to floatM, as in: , , , aliased to doubleM, as in: , , , aliased to intM as in: , , , aliased to uintM as in: , , , aliased to boolM as in: , , , aliased to shortM as in: , , , aliased to ushortM as in: , , , aliased to byteM as in: , , , aliased to floatMxN as in: , , , etc. aliased to doubleMxN as in: , , , etc. aliased to intMxN as in: , , , etc. aliased to boolMxN as in: , , , etc. All combinations of up to four elements, rows, or columns are provided.

  overloads By default, does not provide operators for interaction with standard library streams. This is to permit maximum flexibility for users who wish to define their own formatting (with or without delimiters, row versus column major matrices, human-readable precision or round-trip exact). However, as it is often useful to simply be able to show something when writing small programs, we provide some default stream operator overloads which can be brought into scope with:

  The provided behavior is to output a string using the currently specified stream properties (width, precision, padding, etc) which matches the braced-initialization syntax that could be used to construct that same value, without any extra whitespace.

  User-defined conversions A mechanism exists to define automatic conversions between and user-provided types. As an example, this mechanism has already been used to defined bidirectional conversions between and .

  TODO: Explain

  is a higher order function which accepts a function of the form and repeatedly invokes until all elements have been consumed, before returning . It is approximately equal to a left fold with an initial value. When is a , elements are folded from least to greatest index. When is a , elements are folded in column-major order.

  See also: Reductions

  is a higher order function which accepts a function of the form and applies it to component-wise sets of elements from data structures of compatible shape and dimensions. It is approximately equal to a convolution followed by a map. The shape of the result (that is, whether it is a scalar, vector, or matrix, and the dimensions thereof) is determined by the arguments. If more than one argument is a non-scalar, the shape of those arguments must agree. Scalars can be freely intermixed with non-scalars, and element types can also be freely mixed. The element type of the returned value is determined by the return type of the provided mapping function . The supported call signatures are enumerated in the following table:

  call type of type of type of result type result elements TODO: Explain and SFINAE helpers.

  See also: Component-wise operations

  Improvements in and subsumed by new supports unary, binary, and ternary operations for supports unary and binary operations for and can also be invoked exclusively with scalars, and supports arbitrary numbers of arguments supports mixed element types Template type alias provides the return type of and specializations are now provided provide three-way comparison between compatible types can be invoked with three distinct (but compatible) types provides the a component-wise equivalent to has been generalized to a component-wise operation where any of , , and can be vectors or scalars User can specialize to enable implicit conversions from to , if either type is a , , or is implemented using this facility to serve as an in-library example No undefined behavior according to the C++11 standard Almost all operations which do not internally call functions are , except for and No lambdas are used in , avoiding potential ODR violations Deprecations in has been deprecated between pairs of matrices. Call if the original, component-wise product was intended Call if the algebraic matrix product was intended You can before including to remove all deprecated features.

  Breaking changes in It is intended that compatibility will be restored before officially tagging

  no longer supports Visual Studio 2013. However, it is known to work on GCC 4.9+, Clang 3.5+ in C++11 mode and Visual Studio 2015+. and may only be used with a which is an arithmetic type This requirement will likely be relaxed, but will require specializing some trait type to indicate additional scalar types

上一篇:晚秋野钓困难多,3种天不出门,3种钓位莫下竿,否则十有九空
下一篇:《重返20岁》讲的什么内容和道理

最近更新影视资讯