idpoint theorem

Version 1.0.0 (294 KB) by SAURIN
matlab
0 Downloads
Updated 23 Nov 2023

View License

xCenter = input('Enter the xc: ');
yCenter = input('Enter the yc: ');
radius = input('Enter the radius of the circle: ');% Prompt the user for the radius
circlePoints = [];% Initialize the plotting array
x = 0;
y = radius;
p = 1 - radius;
while x <= y
x = x + 1;
if p < 0
p = p + 2 * x + 1;
else
y = y - 1;
p = p + 2 * (x - y) + 1;
end
circlePoints = [circlePoints;% Store the points using symmetry
xCenter + x, yCenter + y;
xCenter - x, yCenter + y;
xCenter + x, yCenter - y;
xCenter - x, yCenter - y;
xCenter + y, yCenter + x;
xCenter - y, yCenter + x;
xCenter + y, yCenter - x;
xCenter - y, yCenter - x];
end
plot(circlePoints(:, 1), circlePoints(:, 2), 'o');% Plot the circle
axis equal;
title('Circle Generated Using Midpoint Algorithm');
xlabel('X');
ylabel('Y');
MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0