CS5001 Assignment 6 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

This problem is similar to the example shown on slides 21-24 of Lecture 3. Write a program “assignment-6.c” that creates and manages geometric shapes.

Define and typedef a struct Point that contains two double variables x and y. An instance of Point represents a point in Cartsian space.
Define and typedef a struct Circle that contains a double variable radius and a Point variable center.
Define and typedef a struct Rectangle that contains a Point variable origin that is the top left corner of the rectangle, and two double variables width and height.
Create a function distanceofPoints() that takes const pointers to two Point structs, and computes the distance between them. The distance between two points is the square root of the square of the x distances plus the square of the y distances for the two points. The function returns a double.
Create a function intersectsCircles() that takes const pointers to two Circle structs circle1 and circle2and returns true if the two circles intersect and false otherwise. Two circles intersect if the distance between their centers is less than the sum of the two radii (if they are equal, the two circles touch but do not intersect.
Create a function getBoundingBox() that takes a const pointer to a in input parameter Circle, circle and a pointer to a Rectangle result parameter boundingBox. The function sets the fields of Rectangle to the bounding box that encloses the circle. The function returns the Rectangle result parameter pointer.
Create a main program that tests the intersectsCircles() function using the following cases:
circle1 at 0,0 radius 10, and circle2 at 21,0, radius 10: do not intersect
circle1 at 0,0 radius 10, and circle3 at 20, 0, radius 10: do not intersect
circle1 at 0,0 radius 10, and circle4 at 19,0, radius 10: intersect
Also in the main program, test the getBoundingBox() function by declaring an uninitialized Rectangle boundingBox and calling the getBoundingBox() function for circle1, circle2, circle3, and circle4. Print the origin, width, and height of the boundingBox for each circle.