C++ Programming Tutorial


Graphics Programming

Quadratic Surfaces

Draw a Sphere using Ellipses Draw a Sphere using Parametric Equations Draw an Ellipsoid using Parametric Equations

Character Generation

Urdu Alphabets using Stroke Method Urdu Alphabets using Matrix Method


Circular Arc using Trigo. Method Elliptical Arc using Trigo. Method

General Programs

C-Curve of nth order K-Curve of nth order Cubic Bezier Curve Bezier Curve of nth degree Scanfill algorithm Boundary Fill - 8 Connected Point Flood fill algorithm Rotate About Origin Rotate about reference point Scaling about origin Scaling about reference point Polyline translation Reflection in x axis Reflection in y Axis Reflection on any line Midpoint Circle Drawing Bresenhams Line Algorithm (BLA) Generate a pattern Draw a Chess Board Draw a Luddo Board Deterministic Finite Automation for identifier Kurskals algo - Minimum Cost Spanning Tree

Windows Programs

Checkbox like windows Simple windows & buttons Moving message box like windows Text box Graphical Rep. of tower of hanoi Graphical menu - operate it using arrow keys Text animation


Line using Parametric equations Line-Cartesian Slope-Intercept Equation simple imp Line using Cartesian Slope-Intercept Equation Line - BLA - slopes negative and greater than 1 Line - BLA - slopes negative and less than 1 Line - BLA - slopes positive and greater than 1 Line - BLA - slopes positive and less than 1 DDA line drawing algorithm Bresenham line drawing algorithm Cohen sutherland Line clipping algo.

Line Styles

Different kinds of Dashed Lines Different kinds of Thick Lines


Draw a Polygon Draw a Triangle Draw a Rectangle Sutherland-Hodgeman Polygon Clipping Algo


Circle using Trigo. Method Circle using Polynomial Method Circle using Bresenhams Circle algo. Circle using MidPoint Circle algo.


Ellipse using Polynomial Method Ellipse using Trigo. Method Ellipse using MidPoint Ellipse algo.

2D Transformations

Translation Transformation Scaling Transformation Scaling Trans along a Fixed Point Scaling Trans along Arbitrary Direction Rotation Transformation Rotation Trans along a Pivot Point Reflection tran of x-axix, y-axis and w.r.t origin Reflection tran of line y=x and y=-x X-Direction Shear Transformation Y-Direction Shear Transformation

2D Viewing - Clipping

Window-to-Viewport Coordinate Tran Point Clipping Algorithm Cohen-Sutherland Line Clipping Algo Cohen-Sutherland MidPoint Subdivision Line Nicol Lee Nicol algo. for Line Clipping Liang-Barsky Line Clipping Algo Window-to-Viewport Transformaton None-or-All String Clipping Strategy None-or-All Character Clipping Strategy

3D Object Representations

3D object using Polygon-Mesh Rep. 3D object - Translational Sweep Representatiom 3D object - Rotational Sweep Rep.

3D Transformations

3D Rotation Trans along x-axis 3D Rotation Trans along y-axis 3D Rotation Trans along z-axis 3D Reflection Trans along xy-plane 3D Reflection Trans along yz-plane 3D Reflection Trans along zx-plane 3D Shearing Trans along x-axis 3D Shearing Trans along y-axis 3D Shearing Trans along z-axis

Bezier Curves - Surfaces

3D Cubic Bezier Curve 3D Bezier Curve of nth degree 3D Piece-Wise Bezier Curve of nth degree 3D Bezier Surface for MxN control points


3D objects - Standard Perspective Projection 3D obj - Arbitrary Plane and Center of Projection 3D objects using General Perspective Projection 3D obj-Orthographics Proje Parallel onto xy-plane 3D obj-Cavalier Oblique Parallel prj-xy-plane 3D obj-Cabinet Oblique Parallel prj - xy-plane

Fill Algorithm or Area Filling

Geometric shapes using Boundary Geometric shapes - Boundary - Linked List Geometric shapes using Flood Geometric shapes - Flood - Linked-List Polygon using Scan Line Polygon Rectangle using Scan-Line Rectangle Circle using Scan-Line Circle Circle - Scan-Line Circle - Polar Coordinates
 # include <iostream.h>
 # include <graphics.h>
 # include    <conio.h>
 # include     <math.h>

 # define  f                 0.3
 # define  projection_angle   45

 void show_screen( );

 void Sphere(const int,const int,const int,const int);

 void get_projected_point(int&,int&,int&);
 void multiply_matrices(const float[4],const float[4][4],float[4]);

 int main( )
       int driver=VGA;
       int mode=VGAHI;

       int x=0;
       int y=0;
       int z=0;
       int r=0;

         show_screen( );

         cout<<\"Coordinates of Central Point - (x,y,z) :\";


         cout<<\"Enter the value of x = \";

         cout<<\"Enter the value of y = \";

         cout<<\"Enter the value of z = \";

         cout<<\"Radius of the Sphere - r :\";


         cout<<\"Enter the value of r = \";



           outtextxy(110,460,\"Press <Enter> to continue or any other key to exit.\");

         int key=int(getch( ));


       return 0;

 //-----------------------------  Sphere( )  -----------------------------//

 void Sphere(const int _x,const int _y,const int _z,const int r)
       int x=_x;
       int y=_y;
       int z=_z;


       for(int angle=2;angle<=r;angle+=5)

 //---------------------  get_projected_point( )  -----------------------//

 void get_projected_point(int& x,int& y,int& z)
       float fcos0=(f*cos(projection_angle*(M_PI/180)));
       float fsin0=(f*sin(projection_angle*(M_PI/180)));

       float Par_v[4][4]={

       float xy[4]={x,y,z,1};
       float new_xy[4]={0};



 //----------------------  multiply_matrices( )  ------------------------//

 void multiply_matrices(const float matrix_1[4],
                  const float matrix_2[4][4],float matrix_3[4])
       for(int count_1=0;count_1<4;count_1++)
         for(int count_2=0;count_2<4;count_2++)

 //--------------------------  show_screen( )  ---------------------------//

 void show_screen( )
       restorecrtmode( );
       clrscr( );

       cprintf(\"*-********************************-          -********************************-*\");
       cprintf(\"*---------------------------------- \");

       cprintf(\" Sphere \");

       cprintf(\" ----------------------------------*\");
       cprintf(\"*-********************************-          -********************************-*\");

       for(int count=0;count<42;count++)
      cprintf(\"*-*                                                                          *-*\");



    Related Post:
  1. Program that provides an example of passing objects to function using call by reference method

  2. Program to read a Non-Linear equation in one variable, then evaluate it using Bisection Method and display its kD accurate root

  3. Program to show the implementation of Linked List as a Binary Search Tree

  4. Program to show the Urdu Alphabets using Stroke Method

  5. Program to show the projection of 3D objects using Cavalier Oblique Parallel Projection onto xy-plane (i.e. angle=45 deg)

  6. Program of reflection in x axis

  7. Projects of Employee Record Keeping System using nested structure

  8. Program to implement the Prims Algorithm to solve Minimum Spanning Tree Problem (MST) using Graphics and with Mouse support

  9. Program to create a circular linked list

  10. Program that defines template of vector class that provides modify and multiplication facility

  11. Program to compute nCr

  12. Program to illustrate the Bubble Sort

  13. Program of that provides an example of function overloading

  14. Program of displaying graphical menu and operate it using arrow keys

  15. Program to illustrate the binary operator(-) overloading by creating an object of that class

  16. Program to draw a line using Bresenhams Line Algorithm (BLA) for lines with slopes positive and greater than 1

  17. Program to illustrate adding values to the contents of variables whose addresses are in pointers

  18. Program to read a Non Linear Function, construct and display the Difference Table

  19. Program to illustrate the use of call-by-value method in functions

  20. Program that provides an example of static variables in class

Didn't find what you were looking for? Find more on Program to draw a Sphere using Ellipses