Question

In: Computer Science

Write a program that draws the circumscribed circle (also known as the circumcircle) of a given...

Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circle passes through points A, B, and C. These points will be specified by the user by clicking the mouse button. Remember, the three perpendicular bisectors of the three edges of a triangle all pass through one point, the circumcenter, which is the center of the circumscribed circle.

Solutions

Expert Solution

Answer:

MATLAB code to draw circumscribed cirlce for a given triangel ABC:

function [r,cn]=circumcircle(cor,pl)

  if (nargin==1) pl=0,end 
  if (size(cor) ~= [2,3]) 
    error('Needs three vertices of a triangle');
  end
  %error  check computing the area
  ar=polyarea(cor(1,:),cor(2,:));
  if (ar<1e-9)  
    error('Degenerate triangle','Three points are almost collinear');
  end
  %compute the length of sides (AB, BC and CA) of the triangle
  c=norm(cor(:,1)-cor(:,2));
  a=norm(cor(:,2)-cor(:,3));
  b=norm(cor(:,1)-cor(:,3));
  r=a*b*c/(4*ar);
  bar=[a^2*(-a^2+b^2+c^2),b^2*(a^2-b^2+c^2),c^2*(a^2+b^2-c^2)];
  cn=bar(1)*cor(:,1)+bar(2)*cor(:,2)+bar(3)*cor(:,3);
  cn=cn/sum(bar);
  if (pl==1) 
    th=linspace(0,2*pi);
    x=cn(1)+r*cos(th);
    y=cn(2)+r*sin(th);
    pn=[cor,cor(:,1)];plot(x,y,pn(1,:),pn(2,:),'-*');
  end
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

Related Solutions

Write a program that draws the circumscribed circle (also known as the circumcircle) of a given...
Write a program that draws the circumscribed circle (also known as the circumcircle) of a given triangle ABC; this circle passes through points A, B, and C. These points will be specified by the user by clicking the mouse button. Remember, the three perpendicular bisectors of the three edges of a triangle all pass through one point, the circumcenter, which is the center of the circumscribed circle.
Write a program that draws a fixed circle centered at (100, 60) with radius 50. Whenever...
Write a program that draws a fixed circle centered at (100, 60) with radius 50. Whenever the mouse is moved, display a message indicating whether the mouse point is inside the circle at the mouse point or outside of it. Write in Java please.
Write a JavaFX application that draws a circle using a rubberbanding technique. The circle size is...
Write a JavaFX application that draws a circle using a rubberbanding technique. The circle size is determined by a mouse drag. Use the initial mouse press location as the fixed center point of the circle. Compute the distance between the current location of the mouse pointer and the center point to determine the current radius of the circle.
The vertices of a triangle determine a circle, called the circumcircle of the triangle. Show that...
The vertices of a triangle determine a circle, called the circumcircle of the triangle. Show that if P is any point on the circumcircle of a triangle, and X, Y, and Z are the feet of the perpendiculars from P to the sides of the triangle, then X, Y and Z are collinear.
Write a program, circleref.cpp, that inputs a double radius of circle. It should print, given this...
Write a program, circleref.cpp, that inputs a double radius of circle. It should print, given this radius, the circumference of the circle, the area of the circle, the surface area of a sphere with that radius and the area of a sphere with that radius. Each of its computation functions returns its answers in call by reference parameters. Here are the formulas for computation: Circumference = 2 • π • r Circle Area = π • r2 Sphere Surface Area...
in a gui ' in java write a program that draws equal a simple fence with...
in a gui ' in java write a program that draws equal a simple fence with vertical, spaced slats backed by two boards. Behind the fence show a simple house support Make sure the in the und. house is visible between the slats in the fence.
(Display a Circle and Its Attributes) Write a program that displays a circle of random size...
(Display a Circle and Its Attributes) Write a program that displays a circle of random size and calculates and displays the area, radius, diameter and circumference. Use the following equations: diameter = 2 × radius, area = π × radius2, circumference = 2 × π × radius. Use the constant Math.PI for pi (π). All drawing should be done on a subclass of JPanel, and the results of the calculations should be displayed in a read-only JTextArea.
Write a C++ program that prompts the user for the radius of a circle and then...
Write a C++ program that prompts the user for the radius of a circle and then calls inline function circleArea to calculate the area of that circle. It should do it repeatedly until the user enters -1. Use the constant value 3.14159 for π Sample: Enter the radius of your circle (-1 to end): 1 Area of circle with radius 1 is 3.14159 Enter the radius of your circle (-1 to end): 2 Area of circle with radius 2 is...
Write c code program for the following Write a function, circle, which takes the radius of...
Write c code program for the following Write a function, circle, which takes the radius of a circle from the main function and assign the area of the circle to the variable, area, and the perimeter of the circle to the variable, perimeter. Hint: The function should have three variables as input. Since the contents of the variables are to be modified by a function, it is necessary to use pointers. Please type out the full usable program. Thank you.
Write a Python graphics program that draws the following shapes: • window size: 250 x 250...
Write a Python graphics program that draws the following shapes: • window size: 250 x 250 pixels with window title with your name • big circle, 50 pixels radius with center at (125, 125) • two green circles, 10 pixels radius; first one centered at (113, 113) and second centered at (137, 113) • one red line, from (100, 150) to (150, 150) Then answer this, what do you see? (make this a comment in your code)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT