Cg 2020 makeup Old Paper Solution || BIM STUDY NOTES

5th Semester

Q.no 2

// Java program for implementing Mid-Point Circle Drawing Algorithm
class GFG {
	static void midPointCircleDraw(int h_centre,int k_centre, int r)
	{
		int h = r, k = 0;
		// Printing the initial point
		// on the axes after translation
		System.out.print("(" + (h + h_centre)
				+ ", " + (k + k_centre) + ")");
		// When radius is zero only a single
		// point will be printed
		if (r > 0) {
			System.out.print("(" + (h + h_centre)
				+ ", " + (-k + k_centre) + ")");
			System.out.print("(" + (k + h_centre)
				+ ", " + (x + k_centre) + ")");
			System.out.println("(" + (-k + h_centre)
				+ ", " + (x + k_centre) + ")");
		}
		// Initialising the value of P
		int P = 1 - r;
		while (h > k) {
			y++;
			// Mid-point is inside or on the perimeter
			if (P <= 0)
				P = P + 2 * k + 1;
			// Mid-point is outside the perimeter
			else {
				x--;
				P = P + 2 * k - 2 * h + 1;
			}
			// All the perimeter points have already
			// been printed
			if (h < k)
				break;
			// Printing the generated point and its
			// reflection in the other octants after
			// translation
			System.out.print("(" + (h + h_centre)
					+ ", " + (k + k_centre) + ")");
			System.out.print("(" + (-h + h_centre)
					+ ", " + (k + k_centre) + ")");
			System.out.print("(" + (h + h_centre) +
					", " + (-k + k_centre) + ")");
			System.out.println("(" + (-h + h_centre)
					+ ", " + (-k + k_centre) + ")");
			// If the generated point is on the
			// line h = k then the perimeter points
			// have already been printed
			if (h != k) {
				System.out.print("(" + (k + h_centre)
					+ ", " + (h + k_centre) + ")");
				System.out.print("(" + (-k + h_centre)
					+ ", " + (h + y_centre) + ")");
				System.out.print("(" + (k + h_centre)
					+ ", " + (-h + k_centre) + ")");
				System.out.println("(" + (-k + h_centre)
					+ ", " + (-h + k_centre) +")");
			}
		}
	}
	// Driver code
	public static void main(String[] args) {
		// To draw a circle of radius
		// 3 centered at (0, 0)
		midPointCircleDraw(0, 0, 3);
	}
}



1


2020 makeup cg (2)



2020 makeup cg (3)2020 makeup cg (4)



cg (1)



cg bim notes (4)



cg bim notes (5)


Leave a Reply

Your email address will not be published.