diff options
author | Keuin <[email protected]> | 2022-04-16 14:30:48 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-16 14:30:48 +0800 |
commit | bac87e9c4c61a69c5d315f331031d0745ee9d8d2 (patch) | |
tree | 7d7093b3517b9c4956b80632a48a1ab608d47f96 /sphere.h | |
parent | 8d39a453c515b18cd10079ec4b7e45f315f466da (diff) |
Add object::is_on to check whether a point is on the object's surface.
Diffstat (limited to 'sphere.h')
-rw-r--r-- | sphere.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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); } |