Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::Math Namespace Reference

Functions

bool raySphereIntersection (const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &sphere_center, float sphere_radius, Eigen::Vector3f &intersection)
 Computes the intersection point between a ray and a sphere. More...
 
bool rayPlaneIntersection (const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &plane_point, const Eigen::Vector3f &plane_normal, Eigen::Vector3f &intersection)
 Computes the intersection between a ray and a plane. More...
 
bool rayRingIntersection (const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &plane_point, const Eigen::Vector3f &plane_normal, float inner_radius, float outer_radius, Eigen::Vector3f &intersection)
 Computes the intersection between a ray and a ring in 3D space. More...
 
Eigen::Vector3f rayDirection (const Eigen::Vector2f &pixel, const Eigen::Vector2i &viewport_size, const Eigen::Matrix4f &projection_matrix, const Eigen::Affine3f &view_matrix)
 Computes the ray direction given a pixel position and camera matrices. More...
 

Function Documentation

Eigen::Vector3f Tucano::Math::rayDirection ( const Eigen::Vector2f &  pixel,
const Eigen::Vector2i &  viewport_size,
const Eigen::Matrix4f &  projection_matrix,
const Eigen::Affine3f &  view_matrix 
)
inline

Computes the ray direction given a pixel position and camera matrices.

Parameters
pixelScreen coordinates in pixels
viewportSize of viewport
projection_matrixCamera's projection matrix
view_matrixCamera's view matrix
Returns
3D ray direction
bool Tucano::Math::rayPlaneIntersection ( const Eigen::Vector3f &  ray_direction,
const Eigen::Vector3f &  ray_origin,
const Eigen::Vector3f &  plane_point,
const Eigen::Vector3f &  plane_normal,
Eigen::Vector3f &  intersection 
)
inline

Computes the intersection between a ray and a plane.

Parameters
ray_directionRay direction vector normalized
ray_originOrigin of the ray
plane_pointA point on the planed
plane_normalThe normalized normal vector of the plane
interectionIntersection point if any
Returns
True if found an intersection, false otherwise
bool Tucano::Math::rayRingIntersection ( const Eigen::Vector3f &  ray_direction,
const Eigen::Vector3f &  ray_origin,
const Eigen::Vector3f &  plane_point,
const Eigen::Vector3f &  plane_normal,
float  inner_radius,
float  outer_radius,
Eigen::Vector3f &  intersection 
)
inline

Computes the intersection between a ray and a ring in 3D space.

The ring is defined by the space between two concentric circles (with different radii) on a plane The ray intersects the plane with distance d from the center of the cicle if inner_radius >= d >= outer_radius

Parameters
ray_directionRay direction vector normalized
ray_originOrigin of the ray
plane_pointA point on the planed
plane_normalThe normalized normal vector of the plane
inner_radiusRadius of smaller circle
outer_radiusRadius of larger circle
intersectionIntersection point between ray and ring
Returns
True if ray intersects ring, false otherwise
bool Tucano::Math::raySphereIntersection ( const Eigen::Vector3f &  ray_direction,
const Eigen::Vector3f &  ray_origin,
const Eigen::Vector3f &  sphere_center,
float  sphere_radius,
Eigen::Vector3f &  intersection 
)
inline

Computes the intersection point between a ray and a sphere.

Parameters
ray_directionRay direction vector normalized
ray_originOrigin of the ray
sphere_centerCenter of the sphere in same space as ray origin
sphere_radiusRadius of the sphere
interectionIntersection point if any
Returns
True if found an intersection, false otherwise