Ticker

6/recent/ticker-posts

CPNM LAB PROGRAM-8

 


8. Give two points on the surface of the sphere; Write a program to determine the smallest arc length between them. 

                           Flow Chart:-

Algorithm: 
Step – 1 : Start 
Step – 2 : Read the two points on the surface of the sphere 
Step – 3 : Calculate  r =sqrt(pow((x-x1),2)+pow((y-y1),2)+pow((z-z1),2))
Step – 4 : Calculate d=sqrt(pow((x1-x2),2)+pow((y1-y2),2)+pow((z1-z2),2)) 
Step – 5 : Calculate A = 2 * asin (d / (2 * r)) 
Step – 6 : Calculate l = (r * A) 
Step – 7 : Print arc length 
Step – 8 : Stop 

PROGRAM:

#include<stdio.h>


#include<conio.h>


#include<stdlib.h>


#include<math.h>


       main() 

{


int x, y, z, x1, y1, z1, x2, y2, z2; 


double r, l, d, A;


 clrscr();


printf("Enter x, y, z, co-ordinates of the centre of the sphere\n");


scanf("%d%d%d",&x,&y,&z);


printf("Enter x1, y1, z1, co-ordinates \n"); 


scanf("%d%d%d",&x1,&y1,&z1);


printf("Enter x2, y2, z2, co-ordinates \n"); 


scanf("%d%d%d",&x2,&y2,&z2);


r=sqrt(pow((x-x1),2)+pow((y-y1),2)+pow((z-z1),2)); 


d=sqrt(pow((x1-x2),2)+pow((y1-y2),2)+pow((z1-z2),2));


A = 2 * asin(d / (2 * r)); 


l=(r * A);


printf("\nThe smallest arc length between the given points on the sphere is %f limits",l);


 getch();


}


   THIS CODE IS CREATED BY ECE THE WONDERS, HEMU THE SMART

 

OUTPUT :-

Enter x, y, z, co-ordinates of the centre of the sphere

1 2 3

Enter x1, y1, z1, co-ordinates

3 2 3

Enter x2, y2, z2, co-ordinates

1 0 3

 

The smallest arc length between the given points on the sphere is 3.141593 limits

Post a Comment

0 Comments