3.7.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
fcppt::math::vector Namespace Reference

Contains fcppt::math::vector::object vector::object and helper functions, classes and types for it. More...

Classes

struct  has_dim
 Checks the dimension of a vector. More...
 
struct  is_vector
 Checks if a type is a vector type. More...
 
struct  is_vector< fcppt::math::vector::object< T, N, S > >
 
class  object
 A class representing static n-dimensional vectors. More...
 

Typedefs

template<typename T , fcppt::math::size_type N>
using static_ = fcppt::math::vector::object< T, N, fcppt::math::detail::static_storage< T, N > >
 Typedef helper for static vectors. More...
 

Functions

template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::optional::object< T > angle_between (fcppt::math::vector::object< T, N, S1 > const &_from, fcppt::math::vector::object< T, N, S2 > const &_to)
 Calculates the angle between two floating point vectors. More...
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::optional::object< Dest > angle_between_cast (fcppt::math::vector::object< T, N, S1 > const &_from, fcppt::math::vector::object< T, N, S2 > const &_to)
 Calculates the angle between two arbitrary vector types. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_UNARY_TYPE(T, -), N > operator- (fcppt::math::vector::object< T, N, S > const &_left)
 Negates a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,+, R), N > operator+ (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::vector::object< R, N, S2 > const &_right)
 Adds a vector to a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, -, R), N > operator- (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::vector::object< R, N, S2 > const &_right)
 Subtracts a vector from a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > operator* (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::vector::object< R, N, S2 > const &_right)
 Multiplies a vector by a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::optional::object< fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,/, R), N > > operator/ (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::vector::object< R, N, S2 > const &_right)
 Divides a vector by a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > operator* (fcppt::math::vector::object< L, N, S > const &_left, R const &_right)
 Multiplies a vector by a scalar on the right. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > operator* (L const &_left, fcppt::math::vector::object< R, N, S > const &_right)
 Multiplies a vector by a scalar on the left. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S >
fcppt::optional::object< fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,/, R), N > > operator/ (fcppt::math::vector::object< L, N, S > const &_left, R const &_right)
 Divides a vector by a scalar. More...
 
template<fcppt::math::size_type Index, typename Vector >
fcppt::container::to_reference_type< std::remove_reference_t< Vector > > at (Vector &_value)
 Access an element using a compile-time constant. More...
 
template<typename T , typename S >
fcppt::optional::object< T > atan2 (fcppt::math::vector::object< T, 2, S > const &_vector)
 Computes atan2 of a vector. More...
 
template<typename T1 , typename T2 , fcppt::math::size_type N, typename S1 , typename S2 , typename Function >
fcppt::math::vector::static_< std::result_of_t< Function(T1, T2)>, N > binary_map (fcppt::math::vector::object< T1, N, S1 > const &_left, fcppt::math::vector::object< T2, N, S2 > const &_right, Function const &_function)
 Maps over two vectors. More...
 
template<typename T , fcppt::math::size_type N>
fcppt::array::object< fcppt::math::vector::static_< T, N >, fcppt::math::power_of_2< std::size_t > fcppt::math::size_type{N})> bit_strings ()
 Generates vectors consisting of zeros and ones. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::optional::object< fcppt::math::vector::static_< T, N > > ceil_div_signed (fcppt::math::vector::object< T, N, S > const _vector, T const _divisor)
 Division rounded up for signed vectors. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator== (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors for equality. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator!= (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors for disequality. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator< (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors lexicographically. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator> (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors lexicographically. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator<= (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors lexicographically. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool operator>= (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Compares two vectors lexicographically. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
bool componentwise_equal (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2, T const _epsilon)
 Compares two vectors for equality using an epsilon. More...
 
template<typename T , typename S1 , typename S2 >
fcppt::math::vector::static_< T, 3 > cross (fcppt::math::vector::object< T, 3, S1 > const &l, fcppt::math::vector::object< T, 3, S2 > const &r)
 Calculates the cross product of two three-dimensional vectors. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,+, R), N > operator+ (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right)
 Adds a dim to a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, -, R), N > operator- (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right)
 Subtracts a dim from a vector. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L, *, R), N > operator* (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right)
 Multiplies a vector by a dim. More...
 
template<typename L , typename R , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::optional::object< fcppt::math::vector::static_< FCPPT_MATH_DETAIL_BINARY_TYPE(L,/, R), N > > operator/ (fcppt::math::vector::object< L, N, S1 > const &_left, fcppt::math::dim::object< R, N, S2 > const &_right)
 Divides a vector by a dim. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
std::enable_if_t< std::is_floating_point< T >::value, T > distance (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Computes the distance between two floating-point vectors. More...
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S1 , typename S2 >
std::enable_if_t<!std::is_floating_point< T >::value, Dest > distance (fcppt::math::vector::object< T, N, S1 > const &_v1, fcppt::math::vector::object< T, N, S2 > const &_v2)
 Computes the distance between two non floating-point vectors. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
dot (fcppt::math::vector::object< T, N, S1 > const &_left, fcppt::math::vector::object< T, N, S2 > const &_right)
 Calculates the dot product of two vectors. More...
 
template<typename Vector >
Vector fill (fcppt::type_traits::value_type< Vector > const &_value)
 Constructs a static vector with all components set to a given value. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< T, N+1U > hypersphere_to_cartesian (fcppt::math::vector::object< T, N, S > const &_angles)
 Calculate the n dimensional polar coordinates, also called "hyperspherical coordinates". More...
 
template<typename Vector , typename Function >
Vector init (Function const &_function)
 Initializes a vector. More...
 
template<typename T , fcppt::math::size_type N, typename S , typename Ch , typename Traits >
std::basic_istream< Ch, Traits > & operator>> (std::basic_istream< Ch, Traits > &_stream, fcppt::math::vector::object< T, N, S > &_vector)
 Reads a vector from s, expecting it in the format. More...
 
template<typename T , fcppt::math::size_type N, typename S >
std::enable_if_t< std::is_floating_point< T >::value, T > length (fcppt::math::vector::object< T, N, S > const &_vec)
 Calculates the length of a vector. More...
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S >
std::enable_if_t<!std::is_floating_point< T >::value, Dest > length (fcppt::math::vector::object< T, N, S > const &_vec)
 Calculates the length of a vector. More...
 
template<typename T , fcppt::math::size_type N, typename S >
length_square (fcppt::math::vector::object< T, N, S > const &_vector)
 Calculate the square of the vector's length. More...
 
template<typename T , fcppt::math::size_type N, typename S , typename Function >
fcppt::math::vector::static_< std::result_of_t< Function(T)>, N > map (fcppt::math::vector::object< T, N, S > const &_value, Function const &_function)
 Maps over the elements of a vector. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::optional::object< fcppt::math::vector::static_< T, N > > mod (fcppt::math::vector::object< T, N, S > const &_arg, T const _div)
 Calculate vector modulo a scalar. More...
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
fcppt::optional::object< fcppt::math::vector::static_< T, N > > mod (fcppt::math::vector::object< T, N, S1 > const &_v0, fcppt::math::vector::object< T, N, S2 > const &_v1)
 Calculate vector modulo a vector. More...
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S >
Dest narrow_cast (fcppt::math::vector::object< T, N, S > const &_src)
 Shortens a vector to a smaller dimension. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::optional::object< fcppt::math::vector::static_< T, N > > normalize (fcppt::math::vector::object< T, N, S > const &_vec)
 Normalizes a vector. More...
 
template<typename Vector >
fcppt::math::vector::static_< fcppt::type_traits::value_type< Vector >, Vector::static_size::value > null ()
 Returns the null vector. More...
 
template<typename T , fcppt::math::size_type N, typename S , typename Ch , typename Traits >
std::basic_ostream< Ch, Traits > & operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::math::vector::object< T, N, S > const &_vector)
 Outputs a vector to a stream. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< T, N > point_rotate (fcppt::math::vector::object< T, N, S > const &_point, fcppt::math::vector::object< T, N, S > const &_around, T const _rot)
 Rotates a two dimensional point around another point. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< T, N+1 > push_back (fcppt::math::vector::object< T, N, S > const &_vector, T const &_value)
 Pushes an element to the back of a vector. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::optional::object< fcppt::math::vector::static_< T, N > > sequence (fcppt::math::vector::object< fcppt::optional::object< T >, N, S > const &_value)
 Sequence for a vector. More...
 
template<typename T , typename S1 , typename S2 >
fcppt::optional::object< T > signed_angle_between (fcppt::math::vector::object< T, 2, S1 > const &_from, fcppt::math::vector::object< T, 2, S2 > const &_to)
 Calculates the signed angle between two 2D vectors. More...
 
template<typename Dest , typename T , typename S1 , typename S2 >
fcppt::optional::object< Dest > signed_angle_between_cast (fcppt::math::vector::object< T, 2, S1 > const &_from, fcppt::math::vector::object< T, 2, S2 > const &_to)
 Calculates the signed angle between two arbitrary 2D vector types. More...
 
template<typename Dest , typename Conv , typename T , fcppt::math::size_type N, typename S >
Dest structure_cast (fcppt::math::vector::object< T, N, S > const &_src)
 Converts a vector into a different vector of the same dimension. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::dim::static_< T, N > to_dim (fcppt::math::vector::object< T, N, S > const &_src)
 Converts a vector into a corresponding dim. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< std::make_signed_t< T >, N > to_signed (fcppt::math::vector::object< T, N, S > const &_src)
 Converts a vector into a corresponding signed vector. More...
 
template<typename T , fcppt::math::size_type N, typename S >
fcppt::math::vector::static_< std::make_unsigned_t< T >, N > to_unsigned (fcppt::math::vector::object< T, N, S > const &_src)
 Converts a vector into a corresponding unsigned vector. More...
 
template<typename Vec >
Vec unit (typename Vec::size_type const _axis)
 Returns the n-th basis vector of the canonical basis. More...
 

Detailed Description

Contains fcppt::math::vector::object vector::object and helper functions, classes and types for it.