|
Firefly 3.1.0
Standalone library for vector calculations
|
Functions | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | angle_between (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2, double delta=1e-6) |
| Calculates the angle between two vectors in radians. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| bool | are_anti_parallel (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2) |
| Checks if two vectors are anti-parallel. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| bool | are_parallel (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2) |
| Checks if two vectors are parallel. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| bool | are_orthogonal (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2, double delta=1e-6) |
| Checks if two- vectors are orthogonal. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | area_parallelogram (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2) |
| Computes the area of the parallelogram formed by two vectors. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | area_triangle (firefly::vector< T, Length > const &v1, firefly::vector< U, Length > const &v2) |
| Computes the area of the triangle formed by two vectors. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | projection (firefly::vector< T, Length > const &source_vector, firefly::vector< U, Length > const &target_vector) |
| Projects a source vector onto a target vector. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | rejection (firefly::vector< T, Length > const &source_vector, firefly::vector< U, Length > const &target_vector) |
| Rejects a source vector from a target vector. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | distance (firefly::vector< T, Length > const &vector_a, firefly::vector< U, Length > const &vector_b) |
| Computes the Euclidean distance between two vectors. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | reflection (firefly::vector< T, Length > const &source_vector, firefly::vector< U, Length > const &target_vector) |
| Reflects a source vector across a target vector. | |
| template<vector_type T> | |
| constexpr auto | rotate_2d (firefly::vector< T, 2 > const &vector, double angle_rad) |
| Rotates a 2D vector by a given angle (in radians). | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | scalar_projection (firefly::vector< T, Length > const &source_vector, firefly::vector< U, Length > const &target_vector) |
| Computes the scalar projection of a source vector onto a target vector. | |
| template<vector_type T, vector_type U, std::size_t Length> | |
| constexpr auto | lerp (firefly::vector< T, Length > const &vector_a, firefly::vector< U, Length > const &vector_b, double t) |
| Performs linear interpolation (Lerp) between two vectors. | |
|
constexpr |
Calculates the angle between two vectors in radians.
This function computes the angle between two vectors, v1 and v2, of the same length. It uses the dot product and the norms of the vectors to determine the cosine of the angle.
| T | Type of the first vector. Must be an arithmetic type. |
| U | Type of the second vector. Must be an arithmetic type. |
| Length | Length of both vectors. |
| v1 | First vector of type firefly::vector<T, Length>. |
| v2 | Second vector of type firefly::vector<U, Length>. |
| delta | A small tolerance value for numerical stability (default is 1e-6). |
| std::logic_error | when norm is zero. This usually happens when zero vector is passed |
| bool firefly::utilities::vector::are_anti_parallel | ( | firefly::vector< T, Length > const & | v1, |
| firefly::vector< U, Length > const & | v2 | ||
| ) |
Checks if two vectors are anti-parallel.
Two vectors are considered anti-parallel if they are in opposite direction.
| T | Type of the first vector. |
| U | Type of the second vector. |
| Length | Length of both vectors. |
| v1 | First vector of type firefly::vector<T, Length>. |
| v2 | Second vector of type firefly::vector<U, Length>. |
| std::logic_error | when norm is zero. This usually happens when zero vector is passed |
| bool firefly::utilities::vector::are_orthogonal | ( | firefly::vector< T, Length > const & | v1, |
| firefly::vector< U, Length > const & | v2, | ||
| double | delta = 1e-6 |
||
| ) |
Checks if two- vectors are orthogonal.
Two vectors are considered orthogonal if the angle between them is close to 90 degrees (or π/2 radians).
| T | Type of the first vector. |
| U | Type of the second vector. |
| Length | Length of both vectors. |
| v1 | First vector of type firefly::vector<T, Length>. |
| v2 | Second vector of type firefly::vector<U, Length>. |
| delta | A small tolerance value for numerical stability (default is 1e-6). |
| std::logic_error | when norm is zero. This usually happens when zero vector is passed |
| bool firefly::utilities::vector::are_parallel | ( | firefly::vector< T, Length > const & | v1, |
| firefly::vector< U, Length > const & | v2 | ||
| ) |
Checks if two vectors are parallel.
Two vectors are considered parallel if they are same or opposite directions.
| T | Type of the first vector. |
| U | Type of the second vector. |
| Length | Length of both vectors. |
| v1 | First vector of type firefly::vector<T, Length>. |
| v2 | Second vector of type firefly::vector<U, Length>. |
| std::logic_error | when norm is zero. This usually happens when zero vector is passed |
|
constexpr |
Computes the area of the parallelogram formed by two vectors.
| T | The type of the elements in the first vector. |
| U | The type of the elements in the second vector. |
| Length | The number of dimensions of the vectors. |
| v1 | The first vector. |
| v2 | The second vector. |
|
constexpr |
Computes the area of the triangle formed by two vectors.
| T | The type of the elements in the first vector. |
| U | The type of the elements in the second vector. |
| Length | The number of dimensions of the vectors. |
| v1 | The first vector. |
| v2 | The second vector. |
|
constexpr |
Computes the Euclidean distance between two vectors.
| T | The type of the elements in the first vector. |
| U | The type of the elements in the second vector. |
| Length | The number of dimensions of the vectors. |
| vector_a | The first vector. |
| vector_b | The second vector. |
|
constexpr |
Performs linear interpolation (Lerp) between two vectors.
| T | The type of the elements in the first vector. |
| U | The type of the elements in the second vector. |
| Length | The number of dimensions of the vectors. |
| vector_a | The first vector. |
| vector_b | The second vector. |
| t | The interpolation parameter, typically in the range [0, 1]. |
|
constexpr |
Projects a source vector onto a target vector.
| T | The type of the elements in the source vector. |
| U | The type of the elements in the target vector. |
| Length | The number of dimensions of the vectors. |
| source_vector | The vector being projected. |
| target_vector | The vector onto which the source_vector is projected. |
|
constexpr |
Reflects a source vector across a target vector.
| T | The type of the elements in the source vector. |
| U | The type of the elements in the target vector. |
| Length | The number of dimensions of the vectors. |
| source_vector | The vector being reflected. |
| target_vector | The vector across which the source_vector is reflected. |
|
constexpr |
Rejects a source vector from a target vector.
| T | The type of the elements in the source vector. |
| U | The type of the elements in the target vector. |
| Length | The number of dimensions of the vectors. |
| source_vector | The vector being rejected. |
| target_vector | The vector from which the source_vector is rejected. |
|
constexpr |
Rotates a 2D vector by a given angle (in radians).
| T | The type of the elements in the vector. |
| vector | The 2D vector to rotate. |
| angle_rad | The angle in radians to rotate the vector. |
|
constexpr |
Computes the scalar projection of a source vector onto a target vector.
| T | The type of the elements in the source vector. |
| U | The type of the elements in the target vector. |
| Length | The number of dimensions of the vectors. |
| source_vector | The vector being projected. |
| target_vector | The vector onto which the source_vector is projected. |