{"action":"created","comment":{"url":"https://api.github.com/repos/bjz/noise-rs/pulls/comments/68484282","id":68484282,"diff_hunk":"@@ -0,0 +1,100 @@\n+// Copyright 2013 The Noise-rs Developers.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+use num::{Float, Zero};\n+use math;\n+use Module;\n+\n+/// Noise module that outputs the value selected from one of two source\n+/// modules chosen by the output value from a control module.\n+///\n+/// - Source Module 1 outputs a value.\n+/// - Source Module 2 outputs a value.\n+/// - Control Module determines the value to select. If the output value\n+/// from the control module is within a range of values known as the selection\n+/// range, this noise module outputs the value from Source Module 2. Otherwise,\n+/// this noise module outputs the value from Source Module 1.\n+pub struct Select<Lhs, Rhs, Control, U> {\n+    source1: Lhs,\n+    source2: Rhs,\n+    selector: Control,\n+    edge_falloff: U,\n+    lower_bound: U,\n+    upper_bound: U,\n+}\n+\n+impl<Lhs, Rhs, Control, U> Select<Lhs, Rhs, Control, U> {\n+    pub fn new(s1: Lhs, s2: Rhs, c: Control, falloff: U, lower: U, upper: U) -> Select<Lhs, Rhs, Control, U> {\n+        Select {\n+            source1: s1,\n+            source2: s2,\n+            selector: c,\n+            edge_falloff: falloff,\n+            lower_bound: lower,\n+            upper_bound: upper,\n+        }\n+    }\n+}\n+\n+/// Maps a value onto a cubic S-curve.\n+fn s_curve3<T: Float>(a: T) -> T {\n+    a * a * (math::cast::<_, T>(3.0) - (math::cast::<_, T>(2.0) * a))\n+}\n+\n+/// Performs linear interploation between two values.\n+fn linear_interp<T: Float>(lhs: T, rhs: T, a: T) -> T {\n+    ((T::one() - a) * lhs) + (a * rhs)\n+}","path":"src/modules/selectors/select.rs","position":58,"original_position":58,"commit_id":"cf5492823e12d86a4f2423543b4c3c2e3f23dbed","original_commit_id":"cf5492823e12d86a4f2423543b4c3c2e3f23dbed","user":{"login":"Razaekel","id":4242014,"avatar_url":"https://avatars.githubusercontent.com/u/4242014?v=3","gravatar_id":"","url":"https://api.github.com/users/Razaekel","html_url":"https://github.com/Razaekel","followers_url":"https://api.github.com/users/Razaekel/followers","following_url":"https://api.github.com/users/Razaekel/following{/other_user}","gists_url":"https://api.github.com/users/Razaekel/gists{/gist_id}","starred_url":"https://api.github.com/users/Razaekel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Razaekel/subscriptions","organizations_url":"https://api.github.com/users/Razaekel/orgs","repos_url":"https://api.github.com/users/Razaekel/repos","events_url":"https://api.github.com/users/Razaekel/events{/privacy}","received_events_url":"https://api.github.com/users/Razaekel/received_events","type":"User","site_admin":false},"body":"I'll move them to a separate interp module, so I can put other interpolation methods in there as well.","created_at":"2016-06-25T05:09:50Z","updated_at":"2016-06-25T05:09:50Z","html_url":"https://github.com/bjz/noise-rs/pull/104#discussion_r68484282","pull_request_url":"https://api.github.com/repos/bjz/noise-rs/pulls/104","_links":{"self":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/comments/68484282"},"html":{"href":"https://github.com/bjz/noise-rs/pull/104#discussion_r68484282"},"pull_request":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/104"}}},"pull_request":{"url":"https://api.github.com/repos/bjz/noise-rs/pulls/104","id":72635876,"html_url":"https://github.com/bjz/noise-rs/pull/104","diff_url":"https://github.com/bjz/noise-rs/pull/104.diff","patch_url":"https://github.com/bjz/noise-rs/pull/104.patch","issue_url":"https://api.github.com/repos/bjz/noise-rs/issues/104","number":104,"state":"open","locked":false,"title":"WIP: Mutation, Composition, and Utility Generators","user":{"login":"Razaekel","id":4242014,"avatar_url":"https://avatars.githubusercontent.com/u/4242014?v=3","gravatar_id":"","url":"https://api.github.com/users/Razaekel","html_url":"https://github.com/Razaekel","followers_url":"https://api.github.com/users/Razaekel/followers","following_url":"https://api.github.com/users/Razaekel/following{/other_user}","gists_url":"https://api.github.com/users/Razaekel/gists{/gist_id}","starred_url":"https://api.github.com/users/Razaekel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Razaekel/subscriptions","organizations_url":"https://api.github.com/users/Razaekel/orgs","repos_url":"https://api.github.com/users/Razaekel/repos","events_url":"https://api.github.com/users/Razaekel/events{/privacy}","received_events_url":"https://api.github.com/users/Razaekel/received_events","type":"User","site_admin":false},"body":"Opening this WIP PR so I can get feedback on the implementation as I work on it.\r\n\r\nReference Issue: #100 \r\n\r\nCurrently, I've only added the Checkerboard and Constant Generator modules while I worked out the type system and implementation. It ended up similar to Aatch's ValueSourceN trait, without the N portion as I pass that though the function implementation instead. I have not figured out how to implement Aatch's ValueSource with associated Input and Output types yet. Hints would be helpful, since this would make it much simpler to implement dimension-agnostic modules like Select or Constant, as Aatch proposed.\r\n\r\nMy intention is to give every generator/modifier/mutator the Module trait, thereby allowing composition through the use of Modules.\r\n\r\nThe foundation of all the modules I plan to implement is based on libnoise.\r\n\r\nFor a minimal implementation, I'll add the following modules:\r\n- [x] Checkerboard\r\n- [x] Constant\r\n- [x] Cylinders\r\n- [x] Perlin\r\n- [x] Select\r\n\r\nModules to be included in later PRs:\r\nSimple Generators:\r\n- OpenSimplex\r\n- Simplex (2D only, 3D and up is covered by patent)\r\n- Spheres\r\n- Voronoi\r\n\r\nFractal Generators:\r\n- Billow\r\n- Multifractal\r\n- Ridged Multifractal\r\n\r\nCombiners:\r\n- Add\r\n- Max\r\n- Min\r\n- Multiply\r\n- Power\r\n\r\nModifier Modules:\r\n- Abs\r\n- Clamp\r\n- Curve\r\n- Exponent\r\n- Invert\r\n- ScaleBias\r\n- Terrace\r\n\r\nSelector Modules:\r\n- Blend\r\n\r\nTransformer Modules:\r\n- Displace\r\n- RotatePoint\r\n- ScalePoint\r\n- TransformPoint\r\n- Turbulence\r\n\r\nMiscellaneous Modules:\r\n- Cache\r\n\r\nI'm open to other module suggestions, as well. There's probably a bunch more that'd fit under Fractal Generators, since there's a lot of ways to combine perlin noise in octaves.","created_at":"2016-06-05T18:00:12Z","updated_at":"2016-06-25T05:09:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e83857e5f987b73948803339b87b05a348f42eba","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bjz/noise-rs/pulls/104/commits","review_comments_url":"https://api.github.com/repos/bjz/noise-rs/pulls/104/comments","review_comment_url":"https://api.github.com/repos/bjz/noise-rs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bjz/noise-rs/issues/104/comments","statuses_url":"https://api.github.com/repos/bjz/noise-rs/statuses/cf5492823e12d86a4f2423543b4c3c2e3f23dbed","head":{"label":"Razaekel:feature/generators","ref":"feature/generators","sha":"cf5492823e12d86a4f2423543b4c3c2e3f23dbed","user":{"login":"Razaekel","id":4242014,"avatar_url":"https://avatars.githubusercontent.com/u/4242014?v=3","gravatar_id":"","url":"https://api.github.com/users/Razaekel","html_url":"https://github.com/Razaekel","followers_url":"https://api.github.com/users/Razaekel/followers","following_url":"https://api.github.com/users/Razaekel/following{/other_user}","gists_url":"https://api.github.com/users/Razaekel/gists{/gist_id}","starred_url":"https://api.github.com/users/Razaekel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Razaekel/subscriptions","organizations_url":"https://api.github.com/users/Razaekel/orgs","repos_url":"https://api.github.com/users/Razaekel/repos","events_url":"https://api.github.com/users/Razaekel/events{/privacy}","received_events_url":"https://api.github.com/users/Razaekel/received_events","type":"User","site_admin":false},"repo":{"id":57562850,"name":"noise-rs","full_name":"Razaekel/noise-rs","owner":{"login":"Razaekel","id":4242014,"avatar_url":"https://avatars.githubusercontent.com/u/4242014?v=3","gravatar_id":"","url":"https://api.github.com/users/Razaekel","html_url":"https://github.com/Razaekel","followers_url":"https://api.github.com/users/Razaekel/followers","following_url":"https://api.github.com/users/Razaekel/following{/other_user}","gists_url":"https://api.github.com/users/Razaekel/gists{/gist_id}","starred_url":"https://api.github.com/users/Razaekel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Razaekel/subscriptions","organizations_url":"https://api.github.com/users/Razaekel/orgs","repos_url":"https://api.github.com/users/Razaekel/repos","events_url":"https://api.github.com/users/Razaekel/events{/privacy}","received_events_url":"https://api.github.com/users/Razaekel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Razaekel/noise-rs","description":"Procedural noise generation library for Rust.","fork":true,"url":"https://api.github.com/repos/Razaekel/noise-rs","forks_url":"https://api.github.com/repos/Razaekel/noise-rs/forks","keys_url":"https://api.github.com/repos/Razaekel/noise-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Razaekel/noise-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Razaekel/noise-rs/teams","hooks_url":"https://api.github.com/repos/Razaekel/noise-rs/hooks","issue_events_url":"https://api.github.com/repos/Razaekel/noise-rs/issues/events{/number}","events_url":"https://api.github.com/repos/Razaekel/noise-rs/events","assignees_url":"https://api.github.com/repos/Razaekel/noise-rs/assignees{/user}","branches_url":"https://api.github.com/repos/Razaekel/noise-rs/branches{/branch}","tags_url":"https://api.github.com/repos/Razaekel/noise-rs/tags","blobs_url":"https://api.github.com/repos/Razaekel/noise-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Razaekel/noise-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Razaekel/noise-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Razaekel/noise-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Razaekel/noise-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/Razaekel/noise-rs/languages","stargazers_url":"https://api.github.com/repos/Razaekel/noise-rs/stargazers","contributors_url":"https://api.github.com/repos/Razaekel/noise-rs/contributors","subscribers_url":"https://api.github.com/repos/Razaekel/noise-rs/subscribers","subscription_url":"https://api.github.com/repos/Razaekel/noise-rs/subscription","commits_url":"https://api.github.com/repos/Razaekel/noise-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Razaekel/noise-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Razaekel/noise-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Razaekel/noise-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/Razaekel/noise-rs/contents/{+path}","compare_url":"https://api.github.com/repos/Razaekel/noise-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Razaekel/noise-rs/merges","archive_url":"https://api.github.com/repos/Razaekel/noise-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Razaekel/noise-rs/downloads","issues_url":"https://api.github.com/repos/Razaekel/noise-rs/issues{/number}","pulls_url":"https://api.github.com/repos/Razaekel/noise-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/Razaekel/noise-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/Razaekel/noise-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Razaekel/noise-rs/labels{/name}","releases_url":"https://api.github.com/repos/Razaekel/noise-rs/releases{/id}","deployments_url":"https://api.github.com/repos/Razaekel/noise-rs/deployments","created_at":"2016-05-01T06:40:41Z","updated_at":"2016-05-01T06:40:42Z","pushed_at":"2016-06-19T05:03:39Z","git_url":"git://github.com/Razaekel/noise-rs.git","ssh_url":"git@github.com:Razaekel/noise-rs.git","clone_url":"https://github.com/Razaekel/noise-rs.git","svn_url":"https://github.com/Razaekel/noise-rs","homepage":null,"size":272,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bjz:master","ref":"master","sha":"34fde1b30c5eb95f94b7be085d9e12b39b7e7025","user":{"login":"bjz","id":695077,"avatar_url":"https://avatars.githubusercontent.com/u/695077?v=3","gravatar_id":"","url":"https://api.github.com/users/bjz","html_url":"https://github.com/bjz","followers_url":"https://api.github.com/users/bjz/followers","following_url":"https://api.github.com/users/bjz/following{/other_user}","gists_url":"https://api.github.com/users/bjz/gists{/gist_id}","starred_url":"https://api.github.com/users/bjz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjz/subscriptions","organizations_url":"https://api.github.com/users/bjz/orgs","repos_url":"https://api.github.com/users/bjz/repos","events_url":"https://api.github.com/users/bjz/events{/privacy}","received_events_url":"https://api.github.com/users/bjz/received_events","type":"User","site_admin":false},"repo":{"id":11753937,"name":"noise-rs","full_name":"bjz/noise-rs","owner":{"login":"bjz","id":695077,"avatar_url":"https://avatars.githubusercontent.com/u/695077?v=3","gravatar_id":"","url":"https://api.github.com/users/bjz","html_url":"https://github.com/bjz","followers_url":"https://api.github.com/users/bjz/followers","following_url":"https://api.github.com/users/bjz/following{/other_user}","gists_url":"https://api.github.com/users/bjz/gists{/gist_id}","starred_url":"https://api.github.com/users/bjz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjz/subscriptions","organizations_url":"https://api.github.com/users/bjz/orgs","repos_url":"https://api.github.com/users/bjz/repos","events_url":"https://api.github.com/users/bjz/events{/privacy}","received_events_url":"https://api.github.com/users/bjz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bjz/noise-rs","description":"Procedural noise generation library for Rust.","fork":false,"url":"https://api.github.com/repos/bjz/noise-rs","forks_url":"https://api.github.com/repos/bjz/noise-rs/forks","keys_url":"https://api.github.com/repos/bjz/noise-rs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bjz/noise-rs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bjz/noise-rs/teams","hooks_url":"https://api.github.com/repos/bjz/noise-rs/hooks","issue_events_url":"https://api.github.com/repos/bjz/noise-rs/issues/events{/number}","events_url":"https://api.github.com/repos/bjz/noise-rs/events","assignees_url":"https://api.github.com/repos/bjz/noise-rs/assignees{/user}","branches_url":"https://api.github.com/repos/bjz/noise-rs/branches{/branch}","tags_url":"https://api.github.com/repos/bjz/noise-rs/tags","blobs_url":"https://api.github.com/repos/bjz/noise-rs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bjz/noise-rs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bjz/noise-rs/git/refs{/sha}","trees_url":"https://api.github.com/repos/bjz/noise-rs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bjz/noise-rs/statuses/{sha}","languages_url":"https://api.github.com/repos/bjz/noise-rs/languages","stargazers_url":"https://api.github.com/repos/bjz/noise-rs/stargazers","contributors_url":"https://api.github.com/repos/bjz/noise-rs/contributors","subscribers_url":"https://api.github.com/repos/bjz/noise-rs/subscribers","subscription_url":"https://api.github.com/repos/bjz/noise-rs/subscription","commits_url":"https://api.github.com/repos/bjz/noise-rs/commits{/sha}","git_commits_url":"https://api.github.com/repos/bjz/noise-rs/git/commits{/sha}","comments_url":"https://api.github.com/repos/bjz/noise-rs/comments{/number}","issue_comment_url":"https://api.github.com/repos/bjz/noise-rs/issues/comments{/number}","contents_url":"https://api.github.com/repos/bjz/noise-rs/contents/{+path}","compare_url":"https://api.github.com/repos/bjz/noise-rs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bjz/noise-rs/merges","archive_url":"https://api.github.com/repos/bjz/noise-rs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bjz/noise-rs/downloads","issues_url":"https://api.github.com/repos/bjz/noise-rs/issues{/number}","pulls_url":"https://api.github.com/repos/bjz/noise-rs/pulls{/number}","milestones_url":"https://api.github.com/repos/bjz/noise-rs/milestones{/number}","notifications_url":"https://api.github.com/repos/bjz/noise-rs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bjz/noise-rs/labels{/name}","releases_url":"https://api.github.com/repos/bjz/noise-rs/releases{/id}","deployments_url":"https://api.github.com/repos/bjz/noise-rs/deployments","created_at":"2013-07-30T01:42:23Z","updated_at":"2016-06-21T08:39:03Z","pushed_at":"2016-06-19T05:03:39Z","git_url":"git://github.com/bjz/noise-rs.git","ssh_url":"git@github.com:bjz/noise-rs.git","clone_url":"https://github.com/bjz/noise-rs.git","svn_url":"https://github.com/bjz/noise-rs","homepage":null,"size":276,"stargazers_count":54,"watchers_count":54,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":10,"forks":26,"open_issues":10,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/104"},"html":{"href":"https://github.com/bjz/noise-rs/pull/104"},"issue":{"href":"https://api.github.com/repos/bjz/noise-rs/issues/104"},"comments":{"href":"https://api.github.com/repos/bjz/noise-rs/issues/104/comments"},"review_comments":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/104/comments"},"review_comment":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bjz/noise-rs/pulls/104/commits"},"statuses":{"href":"https://api.github.com/repos/bjz/noise-rs/statuses/cf5492823e12d86a4f2423543b4c3c2e3f23dbed"}}}}
{"actor":{"display_login":"Razaekel"}}