Page 86 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 86
Lab on Computer Graphics
Notes Program
#include <stdio.h>
#include <math.h>
#include “program_constants.h”
double ellipse_segment (double A, double B, double X 1 , double Y 1 ,
double X 2 ,
double Y 2 , int *MessageCode);
double ellipse_line_overlap (double PHI, double A, double B, double H,
double K, double X 1 , double Y 1 , double X 2 ,
double Y 2 , int *MessageCode);0010 0011 int main (int argc, char ** argv)
{
double A, B;
double H, K, PHI;
double X 1 , Y 1 ;
double X 2 , Y 2 ;
double area 1 , area 2 ;
int rtn;
char msg[1024];
printf (“Calling ellipse_line_overlap.c\n”);
//-- case shown in Fig 5.3
A = 4;
B = 2;
H = –6;
K = 3;
PHI = 3.*pi/8.0;
X 1 = –3;
Y 1 = 3;
X 2 = –7;
Y 2 = 7;
area 1 = ellipse_line_overlap (PHI, A, B, H, K, X 1 , Y 1 , X 2 , Y 2 , &rtn);
sprintf (msg, “Fig 5.4: area = %15.8f, return_value = %d\n”, area 1 , rtn);
printf (msg);
//-- case shown in Fig.5 3, points reversed
A = 4;
B = 2;
H = –6;
K = 3;
PHI = 3.*pi/8.0;
X 1 = –7;
Y 1 = 7;
X 2 = –3;
Y 2 = 3;
80 LOVELY PROFESSIONAL UNIVERSITY