{"action":"created","comment":{"url":"https://api.github.com/repos/svenstaro/bvh/pulls/comments/80378413","id":80378413,"diff_hunk":"@@ -0,0 +1,175 @@\n+//! Axis Aligned Bounding Boxes.\n+\n+use nalgebra::{Point3, Vector3};\n+use std::f32;\n+use std::ops::Index;\n+\n+/// AABB struct.\n+#[derive(Debug, Copy, Clone)]\n+pub struct AABB {\n+    // Minimum coordinates\n+    pub min: Point3<f32>,\n+\n+    // Maximum coordinates\n+    pub max: Point3<f32>,\n+}\n+\n+/// A trait implemented by things which can be bounded by an `AABB`.\n+pub trait Bounded {\n+    fn aabb(&self) -> AABB;\n+}\n+\n+impl AABB {\n+    /// Creates a new `AABB` with the given bounds.\n+    pub fn new(min: Point3<f32>, max: Point3<f32>) -> AABB {\n+        AABB {\n+            min: min,\n+            max: max,\n+        }\n+    }\n+\n+    /// Creates a new empty `AABB`.\n+    pub fn empty() -> AABB {\n+        AABB {\n+            min: Point3::new(f32::INFINITY, f32::INFINITY, f32::INFINITY),\n+            max: Point3::new(f32::NEG_INFINITY, f32::NEG_INFINITY, f32::NEG_INFINITY),\n+        }\n+    }\n+\n+    /// Returns true if the `Point3` is inside the `AABB`.\n+    pub fn contains(&self, p: &Point3<f32>) -> bool {\n+        p.x >= self.min.x && p.x <= self.max.x && p.y >= self.min.y && p.y <= self.max.y &&\n+        p.z >= self.min.z && p.z <= self.max.z\n+    }\n+\n+    /// Returns true if the `Point3` is approximately inside the `AABB`\n+    /// with respect to some `epsilon`.\n+    pub fn approx_contains_eps(&self, p: &Point3<f32>, epsilon: f32) -> bool {\n+        (p.x - self.min.x) > -epsilon && (p.x - self.max.x) < epsilon &&\n+        (p.y - self.min.y) > -epsilon && (p.y - self.max.y) < epsilon &&\n+        (p.z - self.min.z) > -epsilon && (p.z - self.max.z) < epsilon\n+    }\n+\n+    /// Returns a new minimal `AABB` which contains both this `AABB` and `other`.\n+    pub fn union_aabb(&self, other: &AABB) -> AABB {\n+        AABB::new(Point3::new(self.min.x.min(other.min.x),\n+                              self.min.y.min(other.min.y),\n+                              self.min.z.min(other.min.z)),\n+                  Point3::new(self.max.x.max(other.max.x),\n+                              self.max.y.max(other.max.y),\n+                              self.max.z.max(other.max.z)))\n+    }\n+\n+    /// Returns a new minimal `AABB` which contains both this `AABB` and `other`.\n+    pub fn union_point(&self, other: &Point3<f32>) -> AABB {\n+        AABB::new(Point3::new(self.min.x.min(other.x),\n+                              self.min.y.min(other.y),\n+                              self.min.z.min(other.z)),\n+                  Point3::new(self.max.x.max(other.x),\n+                              self.max.y.max(other.y),\n+                              self.max.z.max(other.z)))\n+    }\n+\n+    /// Returns a new minimal `AABB` which contains both this `AABB` and `other`.\n+    pub fn union_bounded<T: Bounded>(&self, other: &T) -> AABB {","path":"src/aabb.rs","position":74,"original_position":74,"commit_id":"80444e3d5fed3b9dadc7393f1b03c1950cc72719","original_commit_id":"80444e3d5fed3b9dadc7393f1b03c1950cc72719","user":{"login":"alexd2580","id":15080856,"avatar_url":"https://avatars.githubusercontent.com/u/15080856?v=3","gravatar_id":"","url":"https://api.github.com/users/alexd2580","html_url":"https://github.com/alexd2580","followers_url":"https://api.github.com/users/alexd2580/followers","following_url":"https://api.github.com/users/alexd2580/following{/other_user}","gists_url":"https://api.github.com/users/alexd2580/gists{/gist_id}","starred_url":"https://api.github.com/users/alexd2580/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexd2580/subscriptions","organizations_url":"https://api.github.com/users/alexd2580/orgs","repos_url":"https://api.github.com/users/alexd2580/repos","events_url":"https://api.github.com/users/alexd2580/events{/privacy}","received_events_url":"https://api.github.com/users/alexd2580/received_events","type":"User","site_admin":false},"body":"This method is implemented on `Bounded` objects which represent things in 3D space which can be wrapped in an `AABB`.","created_at":"2016-09-25T10:02:43Z","updated_at":"2016-09-25T10:02:43Z","html_url":"https://github.com/svenstaro/bvh/pull/1#discussion_r80378413","pull_request_url":"https://api.github.com/repos/svenstaro/bvh/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/comments/80378413"},"html":{"href":"https://github.com/svenstaro/bvh/pull/1#discussion_r80378413"},"pull_request":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/svenstaro/bvh/pulls/1","id":86539336,"html_url":"https://github.com/svenstaro/bvh/pull/1","diff_url":"https://github.com/svenstaro/bvh/pull/1.diff","patch_url":"https://github.com/svenstaro/bvh/pull/1.patch","issue_url":"https://api.github.com/repos/svenstaro/bvh/issues/1","number":1,"state":"open","locked":false,"title":"Add AABB structure and tests","user":{"login":"alexd2580","id":15080856,"avatar_url":"https://avatars.githubusercontent.com/u/15080856?v=3","gravatar_id":"","url":"https://api.github.com/users/alexd2580","html_url":"https://github.com/alexd2580","followers_url":"https://api.github.com/users/alexd2580/followers","following_url":"https://api.github.com/users/alexd2580/following{/other_user}","gists_url":"https://api.github.com/users/alexd2580/gists{/gist_id}","starred_url":"https://api.github.com/users/alexd2580/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexd2580/subscriptions","organizations_url":"https://api.github.com/users/alexd2580/orgs","repos_url":"https://api.github.com/users/alexd2580/repos","events_url":"https://api.github.com/users/alexd2580/events{/privacy}","received_events_url":"https://api.github.com/users/alexd2580/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-23T16:07:13Z","updated_at":"2016-09-25T10:02:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a2aa47ce5e6410d95eb38d3d4ebaa4dda0a9dafb","assignee":{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false},"assignees":[{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/svenstaro/bvh/pulls/1/commits","review_comments_url":"https://api.github.com/repos/svenstaro/bvh/pulls/1/comments","review_comment_url":"https://api.github.com/repos/svenstaro/bvh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/svenstaro/bvh/issues/1/comments","statuses_url":"https://api.github.com/repos/svenstaro/bvh/statuses/80444e3d5fed3b9dadc7393f1b03c1950cc72719","head":{"label":"svenstaro:aabb","ref":"aabb","sha":"80444e3d5fed3b9dadc7393f1b03c1950cc72719","user":{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false},"repo":{"id":68921740,"name":"bvh","full_name":"svenstaro/bvh","owner":{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/svenstaro/bvh","description":"A fast BVH using SAH in rust","fork":false,"url":"https://api.github.com/repos/svenstaro/bvh","forks_url":"https://api.github.com/repos/svenstaro/bvh/forks","keys_url":"https://api.github.com/repos/svenstaro/bvh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/svenstaro/bvh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/svenstaro/bvh/teams","hooks_url":"https://api.github.com/repos/svenstaro/bvh/hooks","issue_events_url":"https://api.github.com/repos/svenstaro/bvh/issues/events{/number}","events_url":"https://api.github.com/repos/svenstaro/bvh/events","assignees_url":"https://api.github.com/repos/svenstaro/bvh/assignees{/user}","branches_url":"https://api.github.com/repos/svenstaro/bvh/branches{/branch}","tags_url":"https://api.github.com/repos/svenstaro/bvh/tags","blobs_url":"https://api.github.com/repos/svenstaro/bvh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/svenstaro/bvh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/svenstaro/bvh/git/refs{/sha}","trees_url":"https://api.github.com/repos/svenstaro/bvh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/svenstaro/bvh/statuses/{sha}","languages_url":"https://api.github.com/repos/svenstaro/bvh/languages","stargazers_url":"https://api.github.com/repos/svenstaro/bvh/stargazers","contributors_url":"https://api.github.com/repos/svenstaro/bvh/contributors","subscribers_url":"https://api.github.com/repos/svenstaro/bvh/subscribers","subscription_url":"https://api.github.com/repos/svenstaro/bvh/subscription","commits_url":"https://api.github.com/repos/svenstaro/bvh/commits{/sha}","git_commits_url":"https://api.github.com/repos/svenstaro/bvh/git/commits{/sha}","comments_url":"https://api.github.com/repos/svenstaro/bvh/comments{/number}","issue_comment_url":"https://api.github.com/repos/svenstaro/bvh/issues/comments{/number}","contents_url":"https://api.github.com/repos/svenstaro/bvh/contents/{+path}","compare_url":"https://api.github.com/repos/svenstaro/bvh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/svenstaro/bvh/merges","archive_url":"https://api.github.com/repos/svenstaro/bvh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/svenstaro/bvh/downloads","issues_url":"https://api.github.com/repos/svenstaro/bvh/issues{/number}","pulls_url":"https://api.github.com/repos/svenstaro/bvh/pulls{/number}","milestones_url":"https://api.github.com/repos/svenstaro/bvh/milestones{/number}","notifications_url":"https://api.github.com/repos/svenstaro/bvh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/svenstaro/bvh/labels{/name}","releases_url":"https://api.github.com/repos/svenstaro/bvh/releases{/id}","deployments_url":"https://api.github.com/repos/svenstaro/bvh/deployments","created_at":"2016-09-22T13:02:14Z","updated_at":"2016-09-22T13:28:08Z","pushed_at":"2016-09-24T12:30:36Z","git_url":"git://github.com/svenstaro/bvh.git","ssh_url":"git@github.com:svenstaro/bvh.git","clone_url":"https://github.com/svenstaro/bvh.git","svn_url":"https://github.com/svenstaro/bvh","homepage":"","size":15,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"svenstaro:master","ref":"master","sha":"49aca14da268c4418cf50b168a1fba55900e8356","user":{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false},"repo":{"id":68921740,"name":"bvh","full_name":"svenstaro/bvh","owner":{"login":"svenstaro","id":1664,"avatar_url":"https://avatars.githubusercontent.com/u/1664?v=3","gravatar_id":"","url":"https://api.github.com/users/svenstaro","html_url":"https://github.com/svenstaro","followers_url":"https://api.github.com/users/svenstaro/followers","following_url":"https://api.github.com/users/svenstaro/following{/other_user}","gists_url":"https://api.github.com/users/svenstaro/gists{/gist_id}","starred_url":"https://api.github.com/users/svenstaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svenstaro/subscriptions","organizations_url":"https://api.github.com/users/svenstaro/orgs","repos_url":"https://api.github.com/users/svenstaro/repos","events_url":"https://api.github.com/users/svenstaro/events{/privacy}","received_events_url":"https://api.github.com/users/svenstaro/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/svenstaro/bvh","description":"A fast BVH using SAH in rust","fork":false,"url":"https://api.github.com/repos/svenstaro/bvh","forks_url":"https://api.github.com/repos/svenstaro/bvh/forks","keys_url":"https://api.github.com/repos/svenstaro/bvh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/svenstaro/bvh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/svenstaro/bvh/teams","hooks_url":"https://api.github.com/repos/svenstaro/bvh/hooks","issue_events_url":"https://api.github.com/repos/svenstaro/bvh/issues/events{/number}","events_url":"https://api.github.com/repos/svenstaro/bvh/events","assignees_url":"https://api.github.com/repos/svenstaro/bvh/assignees{/user}","branches_url":"https://api.github.com/repos/svenstaro/bvh/branches{/branch}","tags_url":"https://api.github.com/repos/svenstaro/bvh/tags","blobs_url":"https://api.github.com/repos/svenstaro/bvh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/svenstaro/bvh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/svenstaro/bvh/git/refs{/sha}","trees_url":"https://api.github.com/repos/svenstaro/bvh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/svenstaro/bvh/statuses/{sha}","languages_url":"https://api.github.com/repos/svenstaro/bvh/languages","stargazers_url":"https://api.github.com/repos/svenstaro/bvh/stargazers","contributors_url":"https://api.github.com/repos/svenstaro/bvh/contributors","subscribers_url":"https://api.github.com/repos/svenstaro/bvh/subscribers","subscription_url":"https://api.github.com/repos/svenstaro/bvh/subscription","commits_url":"https://api.github.com/repos/svenstaro/bvh/commits{/sha}","git_commits_url":"https://api.github.com/repos/svenstaro/bvh/git/commits{/sha}","comments_url":"https://api.github.com/repos/svenstaro/bvh/comments{/number}","issue_comment_url":"https://api.github.com/repos/svenstaro/bvh/issues/comments{/number}","contents_url":"https://api.github.com/repos/svenstaro/bvh/contents/{+path}","compare_url":"https://api.github.com/repos/svenstaro/bvh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/svenstaro/bvh/merges","archive_url":"https://api.github.com/repos/svenstaro/bvh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/svenstaro/bvh/downloads","issues_url":"https://api.github.com/repos/svenstaro/bvh/issues{/number}","pulls_url":"https://api.github.com/repos/svenstaro/bvh/pulls{/number}","milestones_url":"https://api.github.com/repos/svenstaro/bvh/milestones{/number}","notifications_url":"https://api.github.com/repos/svenstaro/bvh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/svenstaro/bvh/labels{/name}","releases_url":"https://api.github.com/repos/svenstaro/bvh/releases{/id}","deployments_url":"https://api.github.com/repos/svenstaro/bvh/deployments","created_at":"2016-09-22T13:02:14Z","updated_at":"2016-09-22T13:28:08Z","pushed_at":"2016-09-24T12:30:36Z","git_url":"git://github.com/svenstaro/bvh.git","ssh_url":"git@github.com:svenstaro/bvh.git","clone_url":"https://github.com/svenstaro/bvh.git","svn_url":"https://github.com/svenstaro/bvh","homepage":"","size":15,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/1"},"html":{"href":"https://github.com/svenstaro/bvh/pull/1"},"issue":{"href":"https://api.github.com/repos/svenstaro/bvh/issues/1"},"comments":{"href":"https://api.github.com/repos/svenstaro/bvh/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/svenstaro/bvh/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/svenstaro/bvh/statuses/80444e3d5fed3b9dadc7393f1b03c1950cc72719"}}}}
{"actor":{"display_login":"alexd2580"}}