4.6.1
Freundlich's C++ toolkit
|
A class representing static n-dimensional vectors.
A vector is a one-dimensional statically sized array, useful for representing points and directions. For a general introduction on vectors, see Math Classes. For vector's interoperation with fcppt::math::matrix::object, see Operators.
A dimension is very similar to a vector, see Motivation. Vectors and dims can be converted into each other, see Converting from and to vectors.
Additionally, there are arithmetic operators that take a vector on the left-hand side and a dim on the right-hand side. These are defined in fcppt/math/vector/dim.hpp
.
Header file | Description |
---|---|
object_fwd.hpp | Contains fcppt::math::vector::object's declaration. |
object_decl.hpp | Contains fcppt::math::vector::object's definition. |
object_impl.hpp | Contains the definition of fcppt::math::vector::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<< . |
dim.hpp | Contains arithmetic operators to interoperate with fcppt::math::dim::object. |
Classes | |
struct | fcppt::math::vector::has_dim< Vector, Dim > |
Checks the dimension of a vector. More... | |
struct | fcppt::math::vector::is_vector< T > |
Checks if a type is a vector type. More... | |
class | fcppt::math::vector::object< T, N, S > |
A class representing static n-dimensional vectors. More... | |
Typedefs | |
template<typename T, fcppt::math::size_type N> | |
using | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > > | fcppt::math::vector::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 > > | fcppt::math::vector::at (Vector &_value) |
Access an element using a compile-time constant. | |
template<typename T, typename S> | |
fcppt::optional::object< T > | fcppt::math::vector::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 > | fcppt::math::vector::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})> | fcppt::math::vector::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 > > | fcppt::math::vector::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 | fcppt::math::vector::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 | fcppt::math::vector::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 | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > > | fcppt::math::vector::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>) | |
T | fcppt::math::vector::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 | fcppt::math::vector::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> | |
T | fcppt::math::vector::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 | fcppt::math::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 > | fcppt::math::vector::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 | fcppt::math::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 > & | fcppt::math::vector::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>) | |
T | fcppt::math::vector::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 | fcppt::math::vector::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> | |
T | fcppt::math::vector::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 > | fcppt::math::vector::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 > > | fcppt::math::vector::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 > > | fcppt::math::vector::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 | fcppt::math::vector::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 > > | fcppt::math::vector::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 > | fcppt::math::vector::null () |
Returns the null vector. | |
template<typename T, fcppt::math::size_type N, typename S, typename Ch, typename Traits> | |
std::basic_ostream< Ch, Traits > & | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::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 > | fcppt::math::vector::to_unsigned (fcppt::math::vector::object< T, N, S > const &_src) |
Converts a vector into a corresponding unsigned vector. | |
template<typename Vec> | |
Vec | fcppt::math::vector::unit (typename Vec::size_type const _axis) |
Returns the n-th basis vector of the canonical basis. | |
using fcppt::math::vector::static_ = fcppt::math::vector::object<T, N, fcppt::math::detail::static_storage<T, N>> |
Typedef helper for static vectors.
T | The vector's value_type |
See the introduction to fcppt::math::vector::object for more information on static vectors (and on this class).
fcppt::optional::object< T > fcppt::math::vector::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.
The function returns nothing if any of the two vectors have length zero.
If you want to calculate the angle between two vectors whose value type is not a floating point type, see fcppt::math::vector::angle_between_cast .
If you want to calculate the signed angle between two 2D vectors, use fcppt::math::vector::signed_angle_between or fcppt::math::vector::signed_angle_between_cast .
_from
or _to
are very close to zero. fcppt::optional::object< Dest > fcppt::math::vector::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.
Dest | The angle type. Must be a floating point type. |
This function is a generalization of fcppt::math::vector::angle_between in that it calculates the angle between two arbitrary vectors, instead of two floating point vectors.
_from
or _to
are very close to zero.
|
inline |
Access an element using a compile-time constant.
Vector | Must be an fcppt::math::vector::object. |
|
inline |
Computes atan2 of a vector.
Computes atan2(_vector.y(),_vector.x())
. In case x or y is zero, nothing is returned.
The standard C++ functions std::atan2
, defined in cmath
, have the signature:
float atan2(float y,float x) double atan2(double y,double x) long double atan2(long double y,long double x)
These functions can be expressed more intuitively as taking a vector (of a floating-point type), since you don't have to remember to pass in (y,x) instead of (x,y). This is what happens in fcppt's atan2 function.
T | Must be a floating-point type. |
|
inline |
Maps over two vectors.
fcppt::array::object< fcppt::math::vector::static_< T, N >, fcppt::math::power_of_2< std::size_t >(fcppt::math::size_type{N})> fcppt::math::vector::bit_strings | ( | ) |
Generates vectors consisting of zeros and ones.
T | An integral type |
Generates the bit strings of type T
in dimension N
. Examples:
T = int, N = 2: (0,0) (1,0) (0,1) (1,1) T = int, N = 3: (0,0,0) (1,0,0) (0,1,0) (1,1,0) (0,0,1) (1,0,1) (0,1,1) (1,1,1)
Example:
fcppt::optional::object< fcppt::math::vector::static_< T, N > > fcppt::math::vector::ceil_div_signed | ( | fcppt::math::vector::object< T, N, S > const | _vector, |
T const | _divisor ) |
Division rounded up for signed vectors.
Applies fcppt::math::ceil_div_signed to each component. Returns nothing in case _divisor is zero.
|
inline |
Compares two vectors for equality using an epsilon.
fcppt::math::vector::static_< T, 3 > fcppt::math::vector::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.
The cross product is defined here:
T fcppt::math::vector::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.
Dest fcppt::math::vector::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.
|
inline |
Calculates the dot product of two vectors.
The dot product is defined here:
Vector fcppt::math::vector::fill | ( | fcppt::type_traits::value_type< Vector > const & | _value | ) |
Constructs a static vector with all components set to a given value.
Vector | Must be a vector |
_value | The value to fill the vector with |
fcppt::math::vector::static_< T, N+1U > fcppt::math::vector::hypersphere_to_cartesian | ( | fcppt::math::vector::object< T, N, S > const & | _angles | ) |
Calculate the n dimensional polar coordinates, also called "hyperspherical coordinates".
T | The vector's value_type |
N | The vector's dimension type |
S | The vector's storage type |
_angles | An N-1 dimensional vector containing the angles in each dimension |
The formula is taken from:
http://en.wikipedia.org/wiki/Hypersphere#Hyperspherical_coordinates
Given an (n-1)-dimensional angle vector this returns an n-dimensional unit vector in n-dimensional cartesian coordinates. If you want a scaled version of the result, do it yourself using operator*(T,vector)
.
Example:
Note that in two dimensions, you have polar coordinates, and so you need one angle to denote a point on the unit circle. The point then has cartesian coordinates:
(cos(angle),sin(angle))
Just as expected.
In three dimensions, you need two angles, usually called azimuth and inclination to denote a point. The resulting point has the following coordinates:
(cos(inclination),cos(azimuth)*sin(inclination),sin(inclination)*sin(azimuth))
So, if azimuth and inclination are zero, you get the point (1,0,0). In a coordinate system where x points to the right, y to the top and z denotes the "depth" (goes into the screen or out of the screen), you are on the right boundary of the sphere.
The case where inclination is zero can be considered the sphere's "zenith" point, meaning a change in azimuth has no effect on the point's coordinate. This might be counter-intuitive if you're used to a sphere having the zenith point at the top. The formula for the hyperspherical coordinates, however, results in this slight "aberration".
If the inclination is not zero, changing the azimuth towards positive infinity results in a clockwise rotation around the x axis, assuming the viewer looks down the positive x axis.
Changing the inclination towards positive infinity results in a counterclockwise rotation around the z axis, assuming the viewer looks down the positive z axis.
|
inline |
Initializes a vector.
Calls _function
for every index of the vector.
Vector | Must be a vector |
Function | Must be a function of type Vector::value_type (Vector::size_type) |
|
inline |
Calculates the length of a vector.
This is the Euclidean distance (or 2 norm) of the vector. There are two variants of this function. One works only for floating point vectors (so you don't have to specify the return type). The other one works for arbitrary vectors and uses a cast internally.
Example:
|
inline |
Calculates the length of a vector.
This is the Euclidean distance (or 2 norm) of the vector. There are two variants of this function. One works only for floating point vectors (so you don't have to specify the return type). The other one works for arbitrary vectors and uses a cast internally.
Example:
|
inline |
Calculate the square of the vector's length.
_vector | The vector to calculate the length for. |
|
inline |
Maps over the elements of a vector.
fcppt::optional::object< fcppt::math::vector::static_< T, N > > fcppt::math::vector::mod | ( | fcppt::math::vector::object< T, N, S > const & | _arg, |
T const | _div ) |
Calculate vector modulo a scalar.
fcppt::optional::object< fcppt::math::vector::static_< T, N > > fcppt::math::vector::mod | ( | fcppt::math::vector::object< T, N, S1 > const & | _v0, |
fcppt::math::vector::object< T, N, S2 > const & | _v1 ) |
Calculate vector modulo a vector.
|
inline |
Shortens a vector to a smaller dimension.
Dest | Must be a vector with a smaller dimension |
_src | The vector to shorten (narrow) |
The inverse operation is fcppt::math::vector::construct.
|
inlinenodiscard |
Normalizes a vector.
Returns nothing in case the length of _vec is zero.
T | Must be a floating-point type. |
fcppt::math::vector::static_< fcppt::type_traits::value_type< Vector >, Vector::static_size::value > fcppt::math::vector::null | ( | ) |
Returns the null vector.
|
inline |
Compares two vectors for disequality.
|
inline |
Multiplies a vector by a scalar on the right.
|
inline |
Multiplies a vector by a dim.
|
inline |
Multiplies a vector by a vector.
|
inline |
Multiplies a vector by a scalar on the left.
|
inline |
Adds a dim to a vector.
|
inline |
Adds a vector to a vector.
|
inline |
Subtracts a dim from a vector.
|
inline |
Subtracts a vector from a vector.
|
inline |
Negates a vector.
|
inline |
Divides a vector by a scalar.
|
inline |
Divides a vector by a dim.
|
inline |
Divides a vector by a vector.
|
inline |
Outputs a vector to a stream.
Uses the output format
(a_1,a_2,...)
where a_i
are the vector's components.
|
inline |
Compares two vectors for equality.
|
inline |
Reads a vector from s
, expecting it in the format.
(a_1,a_2,...)
where a_i
are the components
fcppt::math::vector::static_< T, N > fcppt::math::vector::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.
_point | The point to rotate |
_around | The point to rotate around |
_rot | The rotation angle |
fcppt::math::vector::static_< T, N+1 > fcppt::math::vector::push_back | ( | fcppt::math::vector::object< T, N, S > const & | _vector, |
T const & | _value ) |
Pushes an element to the back of a vector.
|
inline |
Sequence for a vector.
fcppt::optional::object< T > fcppt::math::vector::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.
Uses fcppt::math::vector::atan2 on the difference between the two vectors. In case this fails, nothing is returned.
If you want to calculate the angle between two vectors whose value type is not a floating-point type, see fcppt::math::vector::signed_angle_between_cast.
If you want to calculate the (unsigned) angle between two vectors of higher dimensions, use fcppt::math::vector::angle_between or fcppt::math::vector::angle_between_cast.
T | Must be a floating-point type. |
fcppt::optional::object< Dest > fcppt::math::vector::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.
This function is a generalization of fcppt::math::vector::signed_angle_between since it calculates the angle between two arbitrary vectors, instead of two floating-point vectors. In case of an error, nothing is returned.
Dest | The angle type. Must be a floating-point type. |
|
inline |
Converts a vector into a different vector of the same dimension.
Dest | The destination vector type (not its value type!) |
Conv | the converter to use for each element |
N | The source vector's dimension |
T | The source vector's value_type |
S | The source vector's storage type |
_src | The vector to cast |
See the introduction to fcppt::math::vector::object for more information on this function (and vector in general).
|
inline |
Converts a vector into a corresponding dim.
|
inline |
Converts a vector into a corresponding signed vector.
|
inline |
Converts a vector into a corresponding unsigned vector.
Vec fcppt::math::vector::unit | ( | typename Vec::size_type const | _axis | ) |
Returns the n-th basis vector of the canonical basis.
Vec | The destination vector type. |
_axis | The basis axis |
Creates a vector of type Vec
with all components set to 0 expect for component _axis
which is set to 1: