<commit_before># ray-aabb

test if a ray intersects an aabb in 3d space

ported from http://www.cs.utah.edu/~awilliam/box/

> <NAME>, <NAME>, <NAME>, and <NAME>
> "An Efficient and Robust Ray-Box Intersection Algorithm"
> Journal of graphics tools, 10(1):49-54, 2005


## install

`npm install ray-aabb`

## use

```javascript
var intersectRayAABB = require('ray-aabb');

// setup an interval in which the ray is valid (i.e. inside the frustnum of a 3d scene)
var near = 0;
var far = 10;

/*
                     _______
                    /      /|
                   /______/ |
                  | |_____|_|
(-1, 1, 0) ---->  | /     | /
                  |/______|/
*/

var ray_origin = [-1, 1, 0];
var box = [
  [0, 0, 0],
  [2, 2, 2]
];
var ray_direction = [1, 0, 0];

// this needs to be computed outside `ray-aabb` to avoid recomputing on every ray cast
var ray_inv_direction = [
  1/ray_direction[0],
  1/ray_direction[1],
  1/ray_direction[2]
];

console.log(intersectRayAABB(ray_origin, ray_direction, ray_inv_direction, box, near, far));
// outputs: true
```

## api surface

all vec3s specified are arrays in the format: `[x, y, z]`

`intersectRayAABB`'s parameters
* `ray_origin` - a vec3 defining the ray origin
* `ray_direction` - a __normalized__ vec3 defining the ray direction
* `ray_inv_direction` - the reciprocal of `ray_direction` - precomputed for performance
* `box` - an array containing two vec3s `[[minx, miny, minz], [maxx, maxy, maxz]]`
* `near` - the starting point of the interval of the ray under test (`0` will start at `ray_origin`)
* `far` - the end of the ray interval under test

## license

[MIT](LICENSE.txt)
<commit_msg>add return value to api surface<commit_after># ray-aabb

test if a ray intersects an aabb in 3d space

ported from http://www.cs.utah.edu/~awilliam/box/

> <NAME>, <NAME>, <NAME>, and <NAME>
> "An Efficient and Robust Ray-Box Intersection Algorithm"
> Journal of graphics tools, 10(1):49-54, 2005


## install

`npm install ray-aabb`

## use

```javascript
var intersectRayAABB = require('ray-aabb');

// setup an interval in which the ray is valid (i.e. inside the frustnum of a 3d scene)
var near = 0;
var far = 10;

/*
                     _______
                    /      /|
                   /______/ |
                  | |_____|_|
(-1, 1, 0) ---->  | /     | /
                  |/______|/
*/

var ray_origin = [-1, 1, 0];
var box = [
  [0, 0, 0],
  [2, 2, 2]
];
var ray_direction = [1, 0, 0];

// this needs to be computed outside `ray-aabb` to avoid recomputing on every ray cast
var ray_inv_direction = [
  1/ray_direction[0],
  1/ray_direction[1],
  1/ray_direction[2]
];

console.log(intersectRayAABB(ray_origin, ray_direction, ray_inv_direction, box, near, far));
// outputs: true
```

## api surface

all vec3s specified are arrays in the format: `[x, y, z]`

`intersectRayAABB`'s parameters
* `ray_origin` - a vec3 defining the ray origin
* `ray_direction` - a __normalized__ vec3 defining the ray direction
* `ray_inv_direction` - the reciprocal of `ray_direction` - precomputed for performance
* `box` - an array containing two vec3s `[[minx, miny, minz], [maxx, maxy, maxz]]`
* `near` - the starting point of the interval of the ray under test (`0` will start at `ray_origin`)
* `far` - the end of the ray interval under test

returns:
 * `true` if intersection detected
 * `false` if no intersection

## license

[MIT](LICENSE.txt)

{'fraction_non_alphanumeric': 0.13382137628111274, 'fraction_numerical': 0.02459736456808199, 'mean_word_length': 2.9264367816091954, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2906913', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1167, 'n_words': 396}