Structures and Pointers – Geometry – Problem #5

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: hard

Problem Statement

You are to define data types for storing the following in a 2-dimensional plane: (a) POINT which takes x and y coordinates, (b) LINE which takes two end points, (c) CIRCLE which takes centre-point and value of radius and (d) axis-parallel RECTANGLE (that means its sides are parallel / perpendicular to the x-y axis) for which you take the left bottom and right top corner points. In the main program, you will appropriately read in a line L, a circle C and a rectangle R. You will then find out whether any two of these pairs (L-C, L-R, C-R) intersect each other and if so, at how many places along with the specific points of intersection. For this, you will write three appropriate functions for finding the answers to these questions for various pairs of intersections. Since these functions will need to return more than one item, appropriate use of structures and pointers may be made, as needed. Save the file as A13_<Roll Number>.c (example A13_21AG10002.c). Build, Run and Test it for the given data as well as your own data. Then upload the .c file for the Assignment. [20 Marks: 5 marks for intermediate submission, 15 marks for final submission] In particular, you will do the following: 1. Define data types for POINT, LINE, CIRCLE and axis-parallel RECTANGLE. Use floating point. 2. Write three functions to find out various intersections between pairs of any two of the following: lines, circles and rectangles (that is, line-circle, line-rectangle, circle-rectangle). These functions will return whether and how many places they intersect, and if they intersect list the points of intersection. 3. In the main program read in a line L, a circle C, a rectangle R. You will then call the appropriate functions for the three possible combinations to return the appropriate results. The results will be printed in a suitable and readable form in the main program and not from within the functions. [Do not call any Library Functions other than scanf, printf. You may use your own user defined non-recursive functions.] Test Data: Test it with your own data for various cases.

Back to Lab Problems
Structures and Pointers/Geometry/Problem #5

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #5

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.