# Calculate Frusum Sphere

This topic is 5128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have my 6 frustum planes ready. Each with their vNormal and a fDistance. How do I draw a sphere to encompass all the planes and eliminate the sphere to each plane test. I wish to go Frusum Sphere to Sphere test.

##### Share on other sites
So i guess you need to find sphere center and radius?
(in fact some result sucks, so i'll have to explain)

First, you need to find intersections of triples of your frustum planes (clickster), to get vertices of your frustum, let name them
N1  N2  AN3  N4

for nearclipplane, and in same order for farclipplane,
F1     F2    BF3     F4

(A and B is centers, more below)

I assume frustum is symmetric. So it's not hard to understand that sphere center is located on center line, that passes points
A=0.5*(N1+N4) , B=0.5*(F1+F4)
(A and B is centers of near and far clipplanes)
That is, sphere center P is at
1.) P=A+t*(B-A)
So we need to find t that distances from sphere center to N1 and F1 is equal. So
(N1-P).(N1-P)=(F1-P).(F1-P)
that is, [squared] distances from vertices to P is equal, and both N1 and F1 is on sphere surface. (frustum is symmetric, so all other near and far points should be on surface too)

So, opening brackets
N1.N1-2N1.P+P.P=F1.F1-2F1.P+P.P
removing equal terms
N1.N1-2N1.P=F1.F1-2F1.P
-2N1.P+2F1.P=F1.F1-N1.N1
2F1.P-2N1.P=F1.F1-N1.N1
(2F1-2N1).P=F1.F1-N1.N1
2*(F1-N1).P=F1.F1-N1.N1
substituting P
2*(F1-N1).(A+t*(B-A))=F1.F1-N1.N1
2*(F1-N1).A + t*2*(F1-N1).(B-A)=F1.F1-N1.N1
t=(F1.F1-N1.N1-2*(F1-N1).A)/(2*(F1-N1).(B-A))

From t we can find sphere center using 1.) , and sphere radius is equal to distance from sphere center to some of fustrum vertices.

What to do to check if my solution is correct:
Check that all frustum vertices have nearly equal distances to sphere center.(the best, "cout" all distances)

Probably it is possible to derive that more elegantly, or derive formula from drawing...

##### Share on other sites
Wow this stuff just keeps getting more intense.
Alright thanks a bunch...the post you said I need to read in the first step is quite complex...Once I get that I understand the rest of what you explained.

Also, I did google first off course.
The results where annoying and often right stupid.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634103
• Total Posts
3015539
×