# Having some trouble with my frustum checking code

I'm trying to check if a bounding sphere is either within or intersecting my frustum. It mostly works but there are cases where it should and it doesn't. The frustum is made up of 6 planes which have a position, direction and normal vector. Sphere has a center and radius value. The frustum is created from translating the mouse coordinates into 3d. If anyone can point me in the right direction it would be greatly appreciated. I'm not great at Maths either.

static float DistanceFromPointToPlane(Plane p, DirectX::SimpleMath::Vector3 point) {
float distance = p.normal.Dot(point - p.position);

return distance;
}

static bool IsSphereInsidePlane(DirectX::SimpleMath::Vector3 sphereCentre, Plane p, float radius) {
float d = DistanceFromPointToPlane(p, sphereCentre);
}

static bool SphereIntersectsPlane(DirectX::SimpleMath::Vector3 sphereCentre, Plane p, float radius) {

• Assuming the "inside" of a plane is the opposite side of the plane.normal, the function IsSphereInsidePlane correctly determines if the sphere is completely inside the plane. The second function correctly determines if the sphere is intersecting. You should either: use both functions to determine if the sphere is inside OR intersect, or better you should change the return value of IsSphereInsidePlane to return d < radius and use only this function, forgetting about the other one. – Turms Jun 4 '19 at 6:05
Assuming the "inside" of a plane is the opposite side of the plane.normal, the function IsSphereInsidePlane correctly determines if the sphere is completely inside the plane. The second function correctly determines if the sphere is intersecting.
You should either: use both functions to determine if the sphere is inside OR intersect, or better you should change the return value of IsSphereInsidePlane to return d < radius and use only this function, forgetting about the other one