How to plot three points with Y axis and angle A ? for rotary axis machine.
1 次查看(过去 30 天)
显示 更早的评论
I'm looking for answer to find centre of circle with three reference points. that is Y - axis and Angle A.
here my refernce points (y1,a1) = (-76.890,6.415); (y2,a2)=(-117.456,9.253);(y3,a3)=(-109.875,-12.304)
回答(1 个)
Paras Gupta
2023-8-22
Greetings,
I understand that you want to find the centre of a circle from three given reference points defined by their y-coordinate and the angle from the y-axis.
The cartesian x-coordinate of the reference points can be computed by multiplying the tangent of the given angle with the given y-coordinate.
% Point 1
y1 = -76.890;
a1 = 6.415;
x1 = y1 * tand(a1);
% Point 2
y2 = -117.456;
a2 = 9.253;
x2 = y2 * tand(a2);
% Point 3
y3 = -109.875;
a3 = -12.304;
x3 = y3 * tand(a3);
The following code can then be used to find the center of the circle passing through these three points.
x = [x1, x2, x3]; % x-coordinates of the points
y = [y1, y2, y3]; % y-coordinates of the points
% Calculate the center of the circle
% Let the centre of the circle be (cx, cy) and its radius be r
% (x1 - cx)^2 + (y1 - cy)^2 = r^2
% (x2 - cx)^2 + (y2 - cy)^2 = r^2
% (x3 - cx)^2 + (y3 - cy)^2 = r^2
% The above three equations can be reduced to the following two equations:
% (x1 - x2) * cx + (y1 - y2) * cy = 0.5 * (x1^2 - x2^2 + y1^2 - y2^2)
% (x2 - x3) * cx + (y2 - y3) * cy = 0.5 * (x2^2 - x3^2 + y2^2 - y3^2)
% This system of equations can be represented by A * center = B, that gives center = A/B
A = [x(1)-x(2), y(1)-y(2); x(2)-x(3), y(2)-y(3)];
B = [0.5*(x(1)^2-x(2)^2+y(1)^2-y(2)^2); 0.5*(x(2)^2-x(3)^2+y(2)^2-y(3)^2)];
center = A\B
% Calculate the radius of the circle
r = sqrt((x(1)-center(1))^2 + (y(1)-center(2))^2);
% We can also plot the circle with points and center
theta = linspace(0, 2*pi, 100);
circle_x = center(1) + r*cos(theta);
circle_y = center(2) + r*sin(theta);
figure;
hold on;
plot(x, y, 'ro', 'MarkerSize', 8); % Plot the points
plot(center(1), center(2), 'b+', 'MarkerSize', 10); % Plot the center
plot(circle_x, circle_y, 'g-'); % Plot the circle
axis equal;
grid on;
legend('Points', 'Center', 'Circle');
Please refer to the documentations given below for more information on the functions used in thecode:
- tand function - https://in.mathworks.com/help/matlab/ref/tand.html
- matrix division - https://in.mathworks.com/help/matlab/ref/mldivide.html
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!