aboutsummaryrefslogtreecommitdiffstats
path: root/src/vec3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vec3.cpp')
-rw-r--r--src/vec3.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/vec3.cpp b/src/vec3.cpp
index 3346973..94b3432 100644
--- a/src/vec3.cpp
+++ b/src/vec3.cpp
@@ -143,3 +143,11 @@ vec3 random_in_hemisphere(const vec3& normal) {
else
return -in_unit_sphere;
}
+
+vec3 random_in_unit_disk() {
+ while (true) {
+ auto p = vec3(randd(-1, 1), randd(-1, 1), 0);
+ if (p.length_sq() >= 1) continue;
+ return p;
+ }
+}