VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
boundingSphere.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <core/math/vector3.h>
6#include <core/shape/ray.h>
7
8namespace visutwin::canvas
9{
15 {
16 public:
18 BoundingSphere(const Vector3& center, float radius);
19
20 const Vector3& center() const { return _center; }
21 void setCenter(const Vector3& center) { _center = center; }
22
23 float radius() const { return _radius; }
24 void setRadius(const float radius) { _radius = radius; }
25
27 [[nodiscard]] BoundingSphere clone() const;
28 [[nodiscard]] bool containsPoint(const Vector3& point) const;
29 bool intersectsRay(const Ray& ray, Vector3* point = nullptr) const;
30 [[nodiscard]] bool intersectsBoundingSphere(const BoundingSphere& sphere) const;
31
32 private:
33 Vector3 _center;
34 float _radius;
35 };
36}
Bounding sphere defined by center and radius for intersection and containment tests.
void setRadius(const float radius)
const Vector3 & center() const
bool intersectsRay(const Ray &ray, Vector3 *point=nullptr) const
bool containsPoint(const Vector3 &point) const
void setCenter(const Vector3 &center)
bool intersectsBoundingSphere(const BoundingSphere &sphere) const
BoundingSphere & copy(const BoundingSphere &src)
Infinite ray defined by origin and direction for raycasting and picking.
Definition ray.h:14
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Definition vector3.h:29