Great question! I want to know the answer, too, or at least an easier one than the one I thought of below. But here’s how I would approach it given my limited knowledge…
I don’t know any OpenGL functions that will do this, but it can be solved by using analytic geometry.
The equation of a cone is of the form z = Ax^2 + By^2. The equation of the plane is defined by somethng like Ax + By + Cz = D What you need to do is solve for z, to get the equation of the intersection.
Example: your cone equation is z = x^2 + y^2, and your plane equation is z = y + 4. The equation of the intersection of the two planes is x^2 + y^2 -y = 4. THe locus of all points (x,y) which satisfy this equation is what you’re looking for. So let’s solve this equation for x, where x = sqrt(4 + y - y^2). Now pick a y where 4 + y - y^2 is a positive number (for example, y = 2). THen solve for x, which in this case will be about 1.414. Lastly, plug x = 1.414 and y = 2 into the equation for the cone, which gives you a z coordinate of 6. Thus, one of the vertices of your intersection is (1.414,2,6). (This example happens to form an intersection that is a parabola). Oh, and you need to make sure the Z value doesn’t exceed the height of your cone – if it does, this is not a point on your finite-sized cone.
Of course the trick is going to be converting the cone you probably specified in terms of height (h)and radius ® in terms of x, y, and z (the plane is defined by the equation of the plane’s normal vector). For the above example (which is an upside down cone, with the point at the origin), I think the equation would be
z = h/r^2*(x^2+y^2)
For a more typical cone that has its base at the origin, and is drawn up int he positive direction, the equation for the cone is probably
z = -h/r^2*(x^2+y^2) + h
(You’ll want to check my derivation, though, becuase I may have made a mistake).
Your challenge will be to find a good way of guessing at least 3 vertices on this intersection to define a triangle. One possible approach is to use Newton’s method, but this requires a good initial guess to make it work.
Does anyone else know a better method for doing this? I would love to know as well.