From bac87e9c4c61a69c5d315f331031d0745ee9d8d2 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 16 Apr 2022 14:30:48 +0800 Subject: Add object::is_on to check whether a point is on the object's surface. --- sphere.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sphere.h') diff --git a/sphere.h b/sphere.h index fa181e7..a5a935e 100644 --- a/sphere.h +++ b/sphere.h @@ -81,6 +81,10 @@ public: return hit; } + bool is_on(const vec3d &p) const override { + return ((p - center).mod2() - radius * radius) < 1e-10; + } + pixel8b color() const override { return pixel8b::from_normalized(1.0, 0.0, 0.0); } -- cgit v1.2.3