View Full Version : quadrics, planar intersection, and conics
Is there an easy way to get the contour vertices of a conic formed by the intersection of a plane (which can be translated and rotated) created with GL_QUADS and a cone created with glutSolidCone or gluCylinder?
Thanks for any help.
02-17-2003, 03:00 AM
This is an interesting question: I think there is an easy answer and I think it is connic sections. This represent how objects more in a 1/r potential. Ie planets orbiting the sun. Their orbits lie on these conic sections. This should give you a good place to start looking. There are four classes:
1) simple circular orbits ( plane lies across cone perpendicular to axis)
2) elliptical orbits (plane lies across cone but notperpendicular to axis (at an angle)
3) asteroids (not sure what it is acalled but asteroid comes in loops behgind the sun and is never seen again) (plane is parrallel to axis)
4) the sun ( plane gose through point on cone)
This should all be well classified and on a web site somewhere.
I shall have a little think and may write more,
02-24-2003, 07:38 PM
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 (r) 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.
Namwob and fringe,
First of all, thanks for your reply.
I have been trying to use CSG techniques and stencil buffer, as mentioned in the "Advanced Graphics Programming Techniques Using OpenGL" tutorial at <http://www.opengl.org/developers/code/tutorials.html>, to get the intersection between the two solids (it is not the ideal solution, but it is enough for me now).
My next move will be:
- to try Namwob's suggestion
- to look better Dave Eberly's Magic Software Library <http://www.magic-software.com/> and
- the Graphics Gems Repository <http://www.acm.org/tog/GraphicsGems/>.
Lot of work to do http://www.opengl.org/discussion_boards/ubb/wink.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.