A class representing static n-dimensional dimensions.
Motivation
Conceptually, a dimension is very similar to an fcppt::math::vector::object. However, it is often useful to distinguish the two on the type level. For example, there are operations that apply to vectors (like the dot product) that make no sense in the context of a dimension. Conversely, there are operations like "take the area of the
dimension" that make no sense for vectors. Also, the lower-dimensional getters for vector (x(),y(),z(),w()) have different names than the lower-dimensional getters for dim (w(),h(),d()).
Converting from and to vectors
To convert a dimension to a vector, use fcppt::math::dim::to_vector:
void f()
{
dim3 const d{1, 2, 3};
std::cout << v << '\n';
}
Conversely, use fcppt::math::vector::to_dim to convert a vector to a dim:
void g()
{
vector3 const v{1, 2, 3};
std::cout << d << '\n';
}
Header files
| Header file | Description |
object_fwd.hpp | Contains fcppt::math::dim::object's declaration. |
object_decl.hpp | Contains fcppt::math::dim::object's definition. |
object_impl.hpp | Contains the definition of fcppt::math::dim::object's member functions. |
object.hpp | Includes object_fwd.hpp, object_decl.hpp and object_impl.hpp. |
arithmetic.hpp | Contains symmetric and scalar arithmetic operators. |
comparison.hpp | Contains all comparison operators. |
input.hpp | Contains operator>>. |
output.hpp | Contains operator<<. |
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_UNARY_TYPE(T, -), N > | fcppt::math::dim::operator- (fcppt::math::dim::object< T, N, S > const &_left) |
| | Negates a dim.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S1, typename S2> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,+, R), N > | fcppt::math::dim::operator+ (fcppt::math::dim::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right) |
| | Adds a dim to a dim.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S1, typename S2> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, -, R), N > | fcppt::math::dim::operator- (fcppt::math::dim::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right) |
| | Subtracts a dim from a dim.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S1, typename S2> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > | fcppt::math::dim::operator* (fcppt::math::dim::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right) |
| | Multiplies a dim by a dim.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S1, typename S2> |
| fcppt::optional::object< fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,/, R), N > > | fcppt::math::dim::operator/ (fcppt::math::dim::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right) |
| | Divides a dim by a dim.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > | fcppt::math::dim::operator* (fcppt::math::dim::object< L, N, S > const &_left, R const &_right) |
| | Multiplies a dim by a scalar on the right.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > | fcppt::math::dim::operator* (L const &_left, fcppt::math::dim::object< R, N, S > const &_right) |
| | Multiplies a dim by a scalar on the left.
|
| template<typename L, typename R, fcppt::math::size_type N, typename S> |
| fcppt::optional::object< fcppt::math::dim::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,/, R), N > > | fcppt::math::dim::operator/ (fcppt::math::dim::object< L, N, S > const &_left, R const &_right) |
| | Divides a dim by a scalar.
|
| template<fcppt::math::size_type Index, typename Dim> |
| fcppt::container::to_reference_type< std::remove_reference_t< Dim > > | fcppt::math::dim::at (Dim &_value) |
| | Access an element using a compile-time constant.
|
| template<typename T1, typename T2, fcppt::math::size_type N, typename S1, typename S2, typename Function> |
| fcppt::math::dim::static_< std::invoke_result_t< Function, T1, T2 >, N > | fcppt::math::dim::binary_map (fcppt::math::dim::object< T1, N, S1 > const &_left, fcppt::math::dim::object< T2, N, S2 > const &_right, Function const &_function) |
| | Maps over two dims.
|
| template<typename T, fcppt::math::size_type N, typename S1, typename S2> |
| bool | fcppt::math::dim::operator== (fcppt::math::dim::object< T, N, S1 > const &_v1, fcppt::math::dim::object< T, N, S2 > const &_v2) |
| | Compares two dims for equality.
|
| template<typename T, fcppt::math::size_type N, typename S1, typename S2> |
| bool | fcppt::math::dim::operator!= (fcppt::math::dim::object< T, N, S1 > const &_v1, fcppt::math::dim::object< T, N, S2 > const &_v2) |
| | Compares two dims for disequality.
|
| template<typename T, fcppt::math::size_type N, typename S1, typename S2> |
| bool | fcppt::math::dim::componentwise_equal (fcppt::math::dim::object< T, N, S1 > const &_v1, fcppt::math::dim::object< T, N, S2 > const &_v2, T const _epsilon) |
| | Compares two dims for equality using an epsilon.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| T | fcppt::math::dim::contents (fcppt::math::dim::object< T, N, S > const &_dim) |
| | Returns the area/volume of the dimension.
|
| template<typename Dim> |
| Dim | fcppt::math::dim::fill (fcppt::type_traits::value_type< Dim > const &_value) |
| | Constructs a static dim with all components set to a given value.
|
| template<typename Dim, typename Function> |
| Dim | fcppt::math::dim::init (Function const &_function) |
| | Initializes a dim.
|
| template<typename T, fcppt::math::size_type N, typename S, typename Ch, typename Traits> |
| std::basic_istream< Ch, Traits > & | fcppt::math::dim::operator>> (std::basic_istream< Ch, Traits > &_stream, fcppt::math::dim::object< T, N, S > &_dim) |
| | Reads a dim from s, expecting it in the format.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| bool | fcppt::math::dim::is_quadratic (fcppt::math::dim::object< T, N, S > const &_dim) |
| | Checks if all elements of the dim are the same.
|
| template<typename T, fcppt::math::size_type N, typename S, typename Function> |
| fcppt::math::dim::static_< std::invoke_result_t< Function, T >, N > | fcppt::math::dim::map (fcppt::math::dim::object< T, N, S > const &_value, Function const &_function) |
| | Maps over the elements of a dim.
|
| template<typename Dest, typename T, fcppt::math::size_type N, typename S> |
| Dest | fcppt::math::dim::narrow_cast (fcppt::math::dim::object< T, N, S > const &_src) |
| | Shortens a dim to a smaller dimension.
|
| template<typename Dim> |
| fcppt::math::dim::static_< fcppt::type_traits::value_type< Dim >, Dim::static_size::value > | fcppt::math::dim::null () |
| | Returns the null dim.
|
| template<typename T, fcppt::math::size_type N, typename S, typename Ch, typename Traits> |
| std::basic_ostream< Ch, Traits > & | fcppt::math::dim::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::math::dim::object< T, N, S > const &_dim) |
| | Outputs a dim to s, in the format.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< T, N+1U > | fcppt::math::dim::push_back (fcppt::math::dim::object< T, N, S > const &_dim, T const &_value) |
| | Pushes an element to the back of a dim.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::optional::object< fcppt::math::dim::static_< T, N > > | fcppt::math::dim::sequence (fcppt::math::dim::object< fcppt::optional::object< T >, N, S > const &_value) |
| | Sequence for a dim.
|
| template<typename Dest, typename Conv, typename T, fcppt::math::size_type N, typename S> |
| Dest | fcppt::math::dim::structure_cast (fcppt::math::dim::object< T, N, S > const &_src) |
| | Converts a dim into a different dim of the same dimension.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< std::make_signed_t< T >, N > | fcppt::math::dim::to_signed (fcppt::math::dim::object< T, N, S > const &_src) |
| | Converts a dim into a corresponding signed dim.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::math::dim::static_< std::make_unsigned_t< T >, N > | fcppt::math::dim::to_unsigned (fcppt::math::dim::object< T, N, S > const &_src) |
| | Converts a dim into a corresponding unsigned dim.
|
| template<typename T, fcppt::math::size_type N, typename S> |
| fcppt::math::vector::static_< T, N > | fcppt::math::dim::to_vector (fcppt::math::dim::object< T, N, S > const &_src) |
| | Converts a dim into a corresponding vector.
|