10template <
typename T, cgv::type::u
int32_type N>
26 return origin + t * direction;
55 fvec<T, 4> world_coord(window_coord.
x(), window_coord.
y(), T(1), T(1));
56 world_coord = inverse(view_projection_matrix) * world_coord;
57 world_coord /= world_coord.
w();
59 origin = eye_position;
60 direction = normalize(
fvec<T, 3>(world_coord) - eye_position);
65 return origin + t * direction;
71typedef fray<unsigned, 2> uray2;
73typedef fray<unsigned, 3> uray3;
75typedef fray<unsigned, 3> uray4;
77typedef fray<int, 2> iray2;
79typedef fray<int, 3> iray3;
81typedef fray<int, 3> iray4;
83typedef fray<float, 2> ray2;
85typedef fray<float, 3> ray3;
87typedef fray<float, 3> ray4;
89typedef fray<double, 2> dray2;
91typedef fray<double, 3> dray3;
93typedef fray<double, 3> dray4;
matrix of fixed size dimensions
A vector with zero based index.
T & y()
return second component
T & x()
return first component
T & w()
return fourth component
fray(const fvec< T, 2 > &screen_coord, const fvec< unsigned, 2 > &viewport_size, const fvec< T, 3 > &eye_position, const fmat< T, 4, 4 > &view_projection_matrix)
Construct a ray from a given screen coordinate and view parameters.
fray(const fvec< T, 3 > &origin, const fvec< T, 3 > &direction)
Construct a ray with given origin and direction.
fray()
Construct an invalid ray with origin at zero and undefined direction.
fvec< T, 3 > position(T t) const
Return the position of the ray at the given distance (ray parameter t) from its origin.
Struct template for fixed n-dimensional rays with arbitrary data type defined by origin and direction...
fray()
Construct an invalid ray with origin at zero and undefined direction.
fray(const fvec< T, N > &origin, const fvec< T, N > &direction)
Construct a ray with given origin and direction.
fvec< T, N > position(float t) const
Return the position of the ray at the given distance (ray parameter t) from its origin.