I was given a a problem to solve, I thought I solved it but my answers don't look like the ones provided.

The Problem

A cone with radius of base `r` and height `h`, is stretched to the left and right by length `a` and `b` respectively such that height of the stretched cones equals to the height of the original cone and apexes of all the three cones are colinear.​

Devise an algorithm to calculate the volume of the union of the two stretched cones (colored blue in the image).

[![image](https://i.stack.imgur.com/tjbOB.png)](https://i.stack.imgur.com/tjbOB.png)

My first question was: what is the volume of a slant cone? What I've found so far is that the formula for the volume of a slant cone is the same as that of a regular cone (which made sense to me).

So I though the answer would be 2 times the area of a cone given by radius `r` and height `h` minus the intersection of the two slant cones, which is also a cone with radius `r`. I just need to find out the height of that smaller cone.

My thought was that I could just take the cross section of of the bodies and handle the problem in 2D. Where the base of the cone will lie on the `x` axis and the center for the circle lies in point `(0,0)`.

What I did was calculate the equation of the line that goes from `(-a,h)` to `(r,0)`. And I would also calculate the equation of the line going from `(-r,0)` to `(b,h)`.

I proceeded to calculate the line equations and then to calculate where they intersect. I would then take `y` value at intersection and use it as the height of the smaller cone.

I really thought I nailed it since when I had a = 0 and b = 0 I got the volume of the original cone. However, when the answers where provided mine didn't match the ones given. Can someone point out the hole in my logic?