How can I solve this problem?

Create a function (x,y,r) = InsideCircle (P1,P2), where P1 = (x1,y1) and P2 = (x2,y2) are the upper left and lower right corners of a rectangle.  The output contains the 'x' and 'y' coordinates of the center of a circle with radius 'r' which is centered inside the input rectangle defined by (p1,p2) and touches only two sides.  What is the value of 'x' , 'y' , 'r' if P1=(30,20) and P2=(10,10).  Is the function header in correct format?

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 9월 23일
편집: Andrei Bobrov 2016년 9월 23일

1 개 추천

function [x,y,r] = InsideCircle (P1,P2)
d = (P1-P2)/2;
r = min(abs(d));
x = P2(1)+d(1);
y = P2(2)+d(2);
end

이 질문은 마감되었습니다.

질문:

2016년 9월 23일

마감:

2021년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by