OpenGL Programming/Quadrics

< OpenGL Programming

Concept

Quadrics are a way to create simple shapes, such as spheres or cylinders, from their maths equations.

Quadrics are usually drawn using the GLU (OpenGL Utility) library. In this tutorial though, we target portability, in particular mobile devices, where GLU may just not be available, or only for OpenGL 1.x, so we'll implement it ourselves. In addition we've get a better understanding than merely call of few functions :)

We can draw quadrics differently:

Solving the equation

So you might ask "How on earth am I going to solve a THREE variables equations???". Well, the answer is to define x and y, using a grid, and compute z.

There are two main ways to draw a grid for x and y values:

Both methods will produce different results visually.

When solving the equation, we'll meet two forms:

Sphere

Equation :

So :

So we have two z solutions for each (x,y) point (except when z = 0).

Links

- Comment on this page

- Recent stats

< OpenGL Programming

Browse & download complete code
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.