BRL-CAD
Generate Rays via Pattern Templates

Functionality for generating patterns of rays. More...

Collaboration diagram for Generate Rays via Pattern Templates:

Files

file  pattern.h
 

Data Structures

struct  rt_pattern_data
 

Macros

#define RT_PATTERN_DATA_INIT_ZERO   {NULL, 0, {0, 0, 0}, {0, 0, 0}, 0, NULL, 0, NULL}
 

Enumerations

enum  rt_pattern_t {
  RT_PATTERN_RECT_ORTHOGRID , RT_PATTERN_RECT_PERSPGRID , RT_PATTERN_CIRC_ORTHOGRID , RT_PATTERN_CIRC_PERSPGRID ,
  RT_PATTERN_CIRC_SPIRAL , RT_PATTERN_ELLIPSE_ORTHOGRID , RT_PATTERN_ELLIPSE_PERSPGRID , RT_PATTERN_CIRC_LAYERS ,
  RT_PATTERN_SPH_LAYERS , RT_PATTERN_SPH_QRAND , RT_PATTERN_UNKNOWN
}
 

Functions

int rt_raybundle_maker (struct xray *rp, double radius, const fastf_t *avec, const fastf_t *bvec, int rays_per_ring, int nring)
 
int rt_pattern (struct rt_pattern_data *data, rt_pattern_t type)
 
int rt_gen_elliptical_grid (struct xrays *rays, const struct xray *center_ray, const fastf_t *avec, const fastf_t *bvec, fastf_t gridsize)
 
int rt_gen_circular_grid (struct xrays *ray_bundle, const struct xray *center_ray, fastf_t radius, const fastf_t *up_vector, fastf_t gridsize)
 
int rt_gen_conic (struct xrays *rays, const struct xray *center_ray, fastf_t theta, vect_t up_vector, int rays_per_radius)
 
int rt_gen_frustum (struct xrays *rays, const struct xray *center_ray, const vect_t a_vec, const vect_t b_vec, const fastf_t a_theta, const fastf_t b_theta, const fastf_t a_num, const fastf_t b_num)
 
int rt_gen_rect (struct xrays *rays, const struct xray *center_ray, const vect_t a_vec, const vect_t b_vec, const fastf_t da, const fastf_t db)
 

Detailed Description

Functionality for generating patterns of rays.

Macro Definition Documentation

◆ RT_PATTERN_DATA_INIT_ZERO

#define RT_PATTERN_DATA_INIT_ZERO   {NULL, 0, {0, 0, 0}, {0, 0, 0}, 0, NULL, 0, NULL}

Definition at line 80 of file pattern.h.

Enumeration Type Documentation

◆ rt_pattern_t

Available ray generation patterns

Enumerator
RT_PATTERN_RECT_ORTHOGRID 

grid of rays with parallel normals

RT_PATTERN_RECT_PERSPGRID 

rays from a point with diverging normals to a grid

RT_PATTERN_CIRC_ORTHOGRID 

circular subset of RECT_ORTHOGRID rays

RT_PATTERN_CIRC_PERSPGRID 

circular subset of RECT_PERSPGRID rays

RT_PATTERN_CIRC_SPIRAL 

rays in a circular spiral pattern

RT_PATTERN_ELLIPSE_ORTHOGRID 

elliptical subset of RECT_ORTHOGRID rays

RT_PATTERN_ELLIPSE_PERSPGRID 

elliptical subset of RECT_PERSPGRID rays

RT_PATTERN_CIRC_LAYERS 

cylindrical layers of circular arrays

RT_PATTERN_SPH_LAYERS 

layers of circular rays with the circle radius of each layer described by slices of a sphere

RT_PATTERN_SPH_QRAND 

quasi-random unbiased spherical volume sampling pattern

RT_PATTERN_UNKNOWN 

unknown pattern

Definition at line 49 of file pattern.h.

Function Documentation

◆ rt_raybundle_maker()

int rt_raybundle_maker ( struct xray rp,
double  radius,
const fastf_t avec,
const fastf_t bvec,
int  rays_per_ring,
int  nring 
)

Initial set of 'xrays' pattern generators that can used to feed a bundle set of rays to rt_shootrays() PRIVATE: this is new API and should be considered private for the time being.

◆ rt_pattern()

int rt_pattern ( struct rt_pattern_data data,
rt_pattern_t  type 
)

Make a bundle of rays around a main ray using a generator

If data is NULL, return -1

If the data in the rt_pattern_data struct does not meet the requirements of the specified pattern, return -2

If data->rays is NULL, return the number of rays that would have been generated.

If data->rays is not NULL and ray_cnt does not match the number of rays that will be generated, return -3.

If data->rays is not NULL and ray_cnt matches the number of rays that will be generated, assign rays to the rays output.

Pattern data for each pattern type:

  • all lengths are in mm;
  • center_ray.r_dir must have unit length, if
  • parameter data arrays are necessary they are the responsibility of the calling function

RT_PATTERN_RECT_ORTHOGRID:

Make a bundle of orthogonal rays around a center ray as a uniform rectangular grid. Grid extents are from -a_vec to a_vec and -b_vec to b_vec.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_vec[0] Direction for up
n_vec[1] Direction for right
n_p[0] Offset between rays in the a direction
n_p[1] Offset between rays in the b direction

RT_PATTERN_RECT_PERSPGRID:

Make a bundle of rays around a main ray in the shape of a frustum as a uniform rectangular grid.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_vec[0] Direction for up
n_vec[1] Direction for right
n_p[0] angle of divergence in the direction of n_vec[0]
n_p[1] angle of divergence in the direction of n_vec[1]

n_p[2] | n_p[3] |

RT_PATTERN_CIRC_ORTHOGRID:

Make a bundle of rays around a main ray using a uniform rectangular grid pattern with a circular extent.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_vec[0] Direction for up
n_p[0] grid size
n_p[1] Radius

RT_PATTERN_CIRC_PERSPGRID:

Make a bundle of rays around a main ray in the shape of a cone, using a uniform rectangular grid.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_vec[0] Direction for up
n_p[0] Angle of divergence of the cone
n_p[1] Number of rays that line on each radial ring of the cone

RT_PATTERN_CIRC_SPIRAL:

Make a concentric set of circles of rays (rings) around a main ray.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_p[0] Pattern maximum radius
n_p[1] Number of rays per ring
n_p[2] Number of rings
n_p[3] Spiral skew

RT_PATTERN_ELLIPSE_ORTHOGRID:

Make a bundle of rays around a main ray using a uniform rectangular grid pattern with an elliptical extent.

Param Description
center_pt, center_dir Initializing ray at center of pattern
n_vec[0] Direction for up
n_vec[1] Direction for right
n_p[0] grid size

RT_PATTERN_ELLIPSE_PERSPGRID:

TODO

RT_PATTERN_CIRC_LAYERS:

TODO

RT_PATTERN_SPH_LAYERS:

TODO

RT_PATTERN_SPH_QRAND:

TODO - maybe start here? http://mathworld.wolfram.com/SpherePointPicking.html

return negative on error (data will be unmodified in error condition) ray count on success (>=0)

If ray count greater than zero, data->rays array will hold rays generated by pattern

The following is an example:

int ray_cnt = 0;
struct rt_pattern_data data = RT_PATTERN_DATA_INIT;
VSET(data.a_vec, 0, 0, 1);
data.p1 = 0.1
data.p2 = 10
ray_cnt = rt_pattern(&data, RT_CIRCULAR_GRID);
if (ray_cnt < 0) {
bu_log("error");
} else {
do_something_with_rays(data.rays);
bu_free(data.rays);
}
int bu_log(const char *,...) _BU_ATTR_PRINTF12
void bu_free(void *ptr, const char *str)
int rt_pattern(struct rt_pattern_data *data, rt_pattern_t type)
#define VSET(o, a, b, c)
Set 3D vector at ‘o’ to have coordinates ‘a’, ‘b’, and ‘c’.
Definition: vmath.h:816
size_t ray_cnt
Definition: pattern.h:71
fastf_t * rays
Definition: pattern.h:70

◆ rt_gen_elliptical_grid()

int rt_gen_elliptical_grid ( struct xrays rays,
const struct xray center_ray,
const fastf_t avec,
const fastf_t bvec,
fastf_t  gridsize 
)

Make a bundle of rays around a main ray using a uniform rectangular grid pattern with an elliptical extent.

avec and bvec a. The gridsize is given in mm.

rp[0].r_dir must have unit length.

◆ rt_gen_circular_grid()

int rt_gen_circular_grid ( struct xrays ray_bundle,
const struct xray center_ray,
fastf_t  radius,
const fastf_t up_vector,
fastf_t  gridsize 
)

Make a bundle of rays around a main ray using a uniform rectangular grid pattern with a circular extent. The radius, gridsize is given in mm.

rp[0].r_dir must have unit length.

◆ rt_gen_conic()

int rt_gen_conic ( struct xrays rays,
const struct xray center_ray,
fastf_t  theta,
vect_t  up_vector,
int  rays_per_radius 
)

Make a bundle of rays around a main ray in the shape of a cone, using a uniform rectangular grid; theta is the angle of divergence of the cone, and rays_per_radius is the number of rays that lie on any given radius of the cone.

center_ray.r_dir must have unit length.

◆ rt_gen_frustum()

int rt_gen_frustum ( struct xrays rays,
const struct xray center_ray,
const vect_t  a_vec,
const vect_t  b_vec,
const fastf_t  a_theta,
const fastf_t  b_theta,
const fastf_t  a_num,
const fastf_t  b_num 
)

Make a bundle of rays around a main ray in the shape of a frustum as a uniform rectangular grid. a_vec and b_vec are the directions for up and right, respectively; a_theta and b_theta are the angles of divergence in the directions of a_vec and b_vec respectively. This is useful for creating a grid of rays for perspective rendering.

◆ rt_gen_rect()

int rt_gen_rect ( struct xrays rays,
const struct xray center_ray,
const vect_t  a_vec,
const vect_t  b_vec,
const fastf_t  da,
const fastf_t  db 
)

Make a bundle of orthogonal rays around a center ray as a uniform rectangular grid. a_vec and b_vec are the directions for up and right, respectively; their magnitudes determine the extent of the grid (the grid extends from -a_vec to a_vec in the up-direction and from -b_vec to b_vec in the right direction). da and db are the offset between rays in the a and b directions respectively.