CG programming for non-programmers, lesson 20

In lesson 20 we finally move from 2D graphics to 3D graphics. Specifically we go from flat disks to spheres.

To do this we just use some high school math. For a sphere of radius r, you probably learned in high school that for any point (x,y,z) on the sphere surface the following is true:

      x2 + y2 + z2 = r2

From there it is pretty easy to show that if you already know x,y and r, you can find z by:

      z = sqrt(r2 - x2 - y2)

We use this formula to create a sphere, which we will do cool things with in coming lessons.

You can see this lesson by CLICKING HERE.

2 thoughts on “CG programming for non-programmers, lesson 20”

  1. Again, so FUN!!!

    > float radius = 0.2 * sin(uTime * 1.7 + 2.3* noise(vPos)) + 0.5; // radius OF SPHERE

Leave a Reply

Your email address will not be published. Required fields are marked *