How much of a given object can I cover from 1 fixed point, without going outside a defined boundary?

1 visualizzazione (ultimi 30 giorni)
See image; this shows a growth plate (a little crooked), with a margin (of say 1 mm) drawn above and below it, this is the dotted line. The red dot is a drill bit of certain diameter, hence the circle. This drill breaks the growth plate and may not break or reach anything outside of the dotted line. The idea is that at each point on the growth plate, it is calculated whether this point can be reached from the starting point of the drill without going outside this dotted line. For example, in the illustration, red can do this but green cannot, it will get outside the dotted line.
My idea now is to place the drill in the origin and to make the arc of the growth disk a function with x = ... and y= ... and thus calculate the DistanceFromOrigin each time. Only here I am not taking into account the boundary represented by the dotted line. Can anyone help me how to start?

Risposte (1)

Harsha Vardhan
Harsha Vardhan il 12 Gen 2024
Hi,
I see that you are seeking advice on verifying the extent to which a drill bit can cover a growth plate from a single fixed point, ensuring that the bit does not exceed a specified buffer zone.
Further developing on your idea of modelling the growth disk’s curve as a function, let us follow this step-by-step approach:
  1. Constructing the Model: To assess the coverage, we model the growth plate and buffer zone as curves on a 2D plane, which allow us to analyse the relationship between the drill bit's reach and the growth plate's boundaries.
  2. Representing the Drill Bit: We simplify the 3D shape of the drill bit’s circular tip to a line in 2D space, equal to the diameter of the actual drill bit.
  3. Determining Reachable Points: We calculate the distances from the origin to each point on the growth plate and check whether these points were reachable by the drill bit without infringing on the buffer zone.
Please refer to the below sample code implementation of the above steps:
% Define the functional forms for the growth plate curves
growth_plate_upper = @(x) -0.0005*x.^2 + 15;
growth_plate_lower = @(x) -0.0005*x.^2 + 13; % 2 units below the upper curve for a wider gap
% Define the functional forms for the buffer zone curves with a 1 unit offset
buffer_zone_upper = @(x) growth_plate_upper(x) + 1; % 1 unit above the upper curve
buffer_zone_lower = @(x) growth_plate_lower(x) - 1; % 1 unit below the lower curve
% Define the drill bit diameter and half of it as the radius
drill_diameter = 0.5; % A reasonable value for the diameter of the drill bit
drill_radius = drill_diameter / 2;
% Define the x range over which you want to calculate the distances
x_min = 0; % The minimum x value
x_max = 50; % The maximum x value
num_points = 1000; % The number of points at which you wish to calculate the distances
% Create arrays to store the distances and reachability
distances_from_origin_upper = zeros(1, num_points);
distances_from_origin_lower = zeros(1, num_points);
reachable_upper = false(1, num_points);
reachable_lower = false(1, num_points);
% Define the x-coordinates at which you will calculate the distances
x_values = linspace(x_min, x_max, num_points);
% Loop over the range of x values
for i = 1:num_points
x = x_values(i);
% Calculate the y-coordinates on the growth plate curves
y_growth_upper = growth_plate_upper(x);
y_growth_lower = growth_plate_lower(x);
% Calculate the distances from the origin to these points on the growth plate curves
distances_from_origin_upper(i) = sqrt(x^2 + y_growth_upper^2);
distances_from_origin_lower(i) = sqrt(x^2 + y_growth_lower^2);
% Check if the drill bit, when centered at these points, would intersect the buffer zone
% This is equivalent to checking if the y-coordinates minus half the drill diameter
% are above the lower buffer and the y-coordinates plus half the drill diameter
% are below the upper buffer
if (y_growth_upper - drill_radius >= buffer_zone_lower(x)) && (y_growth_upper + drill_radius <= buffer_zone_upper(x))
reachable_upper(i) = true;
end
if (y_growth_lower - drill_radius >= buffer_zone_lower(x)) && (y_growth_lower + drill_radius <= buffer_zone_upper(x))
reachable_lower(i) = true;
end
end
% Plot the curves
figure;
hold on;
plot(x_values, growth_plate_upper(x_values), 'b-', 'LineWidth', 2); % Upper curve of the growth plate in bold
plot(x_values, growth_plate_lower(x_values), 'b-', 'LineWidth', 2); % Lower curve of the growth plate in bold
plot(x_values, buffer_zone_upper(x_values), 'r--'); % Upper buffer margin in dotted line
plot(x_values, buffer_zone_lower(x_values), 'r--'); % Lower buffer margin in dotted line
xlabel('x-axis');
ylabel('y-axis');
title('Growth Plate and Buffer Zone');
% Place the legend outside the axes to the east (right side)
legend('Growth Plate Upper', 'Growth Plate Lower', 'Buffer Upper', 'Buffer Lower', 'Location', 'eastoutside');
hold off;
Executing the above code will store the distances of various points of the growth plate from the origin in the variablesdistances_from_origin_upper’ and ‘distances_from_origin_lower’.
Similarly, whether a point is reachable without going outside the dotted line is stored in the variables reachable_upper’ and ‘ reachable_lower’.
You may check below the plots of the sample functions modelling the growth plate and the dotted margin line.
In the code, replace ‘growth_plate_upper’, ‘growth_plate_lower’, ‘buffer_zone_upper’, and ‘buffer_zone_lower’ with your actual functions. The ‘drill_diameter’ is set to 0.5 units, but you may adjust this to reflect the actual size of the drill bit used in the procedure.
An alternate solution can be to use the ‘checkCollision’ function from the Robotic System Toolbox. This function checks if 2 geometries are in collision. You may have to map your curves and drill tip to those geometries. Please refer to its documentation here: https://www.mathworks.com/help/robotics/ref/checkcollision.html
I hope you find the information provided to be useful!

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by