Go to the documentation of this file. 1 #ifndef EAGINE_MATH_PRIMITIVES_HPP
9 #define EAGINE_MATH_PRIMITIVES_HPP
18 template <
typename T,
int N,
bool V>
41 return _origin + _direction * t;
51 template <
typename T,
bool V>
56 template <
typename T,
int N,
bool V>
67 : _vertices{{
a,
b,
c}} {}
72 return _vertices[index];
76 constexpr
auto a() const noexcept ->
vector<T, N, V> {
81 constexpr
auto b() const noexcept ->
vector<T, N, V> {
86 constexpr
auto c() const noexcept ->
vector<T, N, V> {
91 constexpr
auto ab() const noexcept ->
vector<T, N, V> {
96 constexpr
auto ac() const noexcept ->
vector<T, N, V> {
102 return (
a() +
b() +
c()) / T(3);
111 std::array<vector<T, N, V>, 3> _vertices{};
116 template <
typename T,
bool V>
121 template <
typename T,
int N,
bool V>
137 constexpr
auto radius() const noexcept -> T {
147 template <
typename T,
bool V>
152 #endif // EAGINE_MATH_PRIMITIVES_HPP
constexpr auto direction() const noexcept -> vector< T, N, V >
Returns the line direction.
Definition: primitives.hpp:35
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
constexpr auto c() const noexcept -> vector< T, N, V >
Returns the third point of the triangle.
Definition: primitives.hpp:86
Basic template for spheres in N-dimensional space.
Definition: primitives.hpp:122
static constexpr auto from(const vector< P, M, W > &v, T d=T(0)) noexcept
Creates vector instance from vector of another dimension.
Definition: vector.hpp:111
constexpr basic_triangle() noexcept=default
Default constructor.
constexpr basic_sphere(tvec< T, N, V > cntr, T rad) noexcept
Construction from center point and radius value.
Definition: primitives.hpp:128
Basic template for lines in N-dimensional space.
Definition: primitives.hpp:19
constexpr auto center() const noexcept -> vector< T, N, V >
Returns the center of the triangle.
Definition: primitives.hpp:101
constexpr basic_line(tvec< T, N, V > orig, tvec< T, N, V > dir) noexcept
Construction from origin point and direction vector.
Definition: primitives.hpp:25
Basic template for triangles in N-dimensional space.
Definition: primitives.hpp:57
Generic template for N-dimensional vectors.
Definition: fwd.hpp:22
constexpr auto vertex(span_size_t index) const noexcept -> vector< T, N, V >
Returns the point at the specified index.
Definition: primitives.hpp:71
Basic N-dimensional vector implementation template.
Definition: fwd.hpp:19
constexpr auto point_at(T t) const noexcept -> vector< T, N, V >
Returns a point on the line at the specified parameter t.
Definition: primitives.hpp:40
constexpr auto center() const noexcept -> vector< T, N, V >
Returns the sphere center.
Definition: primitives.hpp:132
constexpr basic_sphere() noexcept=default
Default constructor.
constexpr auto radius() const noexcept -> T
Returns the sphere radius.
Definition: primitives.hpp:137
Math-related code is placed in this namespace.
Definition: eagine.hpp:48
constexpr basic_triangle(tvec< T, N, V > a, tvec< T, N, V > b, tvec< T, N, V > c) noexcept
Construction from three points making up the triangle.
Definition: primitives.hpp:63
constexpr auto ac() const noexcept -> vector< T, N, V >
Returns the ac edge vector of the triangle.
Definition: primitives.hpp:96
constexpr auto origin() const noexcept -> vector< T, N, V >
Returns the line origin.
Definition: primitives.hpp:30
constexpr auto b() const noexcept -> vector< T, N, V >
Returns the second point of the triangle.
Definition: primitives.hpp:81
constexpr basic_line() noexcept=default
Default constructor.
constexpr auto ab() const noexcept -> vector< T, N, V >
Returns the ab edge vector of the triangle.
Definition: primitives.hpp:91
static auto cross(const vector< T, 3, V > &a, const vector< T, 3, V > &b) noexcept
3D vector cross product.
Definition: vector.hpp:326
constexpr auto normal(bool cw) const noexcept -> vector< T, N, V >
Returns the normal vector of the triangle, in specified direction.
Definition: primitives.hpp:106
constexpr auto a() const noexcept -> vector< T, N, V >
Returns the first point of the triangle.
Definition: primitives.hpp:76