4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
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  has_dim< fcppt::math::vector::object< T, N, S >, Dim >
 
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.
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
template<typename T , typename S >
fcppt::optional::object< T > atan2 (fcppt::math::vector::object< T, 2, S > const &_vector)
 Computes atan2 of a vector.
 
template<typename T1 , typename T2 , fcppt::math::size_type N, typename S1 , typename S2 , typename Function >
fcppt::math::vector::static_< std::invoke_result_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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
template<typename T , fcppt::math::size_type N, typename S1 , typename S2 >
requires (std::is_floating_point_v<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.
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S1 , typename S2 >
requires (!std::is_floating_point_v<T>)
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.
 
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.
 
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.
 
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".
 
template<typename Vector , typename Function >
Vector init (Function const &_function)
 Initializes a vector.
 
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.
 
template<typename T , fcppt::math::size_type N, typename S >
requires (std::is_floating_point_v<T>)
length (fcppt::math::vector::object< T, N, S > const &_vec)
 Calculates the length of a vector.
 
template<typename Dest , typename T , fcppt::math::size_type N, typename S >
requires (!std::is_floating_point_v<T>)
Dest length (fcppt::math::vector::object< T, N, S > const &_vec)
 Calculates the length of a vector.
 
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.
 
template<typename T , fcppt::math::size_type N, typename S , typename Function >
fcppt::math::vector::static_< std::invoke_result_t< Function, T >, N > map (fcppt::math::vector::object< T, N, S > const &_value, Function const &_function)
 Maps over the elements of a vector.
 
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.
 
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.
 
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.
 
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.
 
template<typename Vector >
fcppt::math::vector::static_< fcppt::type_traits::value_type< Vector >, Vector::static_size::value > null ()
 Returns the null vector.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
template<typename Vec >
Vec unit (typename Vec::size_type const _axis)
 Returns the n-th basis vector of the canonical basis.
 

Detailed Description

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