How to provide curvature to a line?

5 次查看(过去 30 天)
Ahmed Anas
Ahmed Anas 2020-3-14
编辑: Altaïr 2025-6-4
Lets we have three points having coordinates as follows:
A(0,0)
B(6,4.5)
C(12,4.5)
and we have to draw line between these three points. Its simple as it can be seen in the code. Now the point B got a displacement of x=0.46 and y= -1.79 and new coordinates of B becomes (6.46,2.71). Also it has rotation of -5.278*10^(-4) rad. Now how to draw the deflected shape is an issue, as am not getting how to give curvature (rotation). Is there any built function for doing this?
The actual and deflected shape picture has been also attached right below for consideration.
Thanks
% Original Shape
x=[0;6;12]; %% x coordinates
y=[0;4.5;4.5]; %% y coordinates
plot(x,y,'g') %% plotting
  4 个评论
darova
darova 2020-3-14
I only see straight lines. Can you show curvature?
Ahmed Anas
Ahmed Anas 2020-3-14
You can see the difference between two lines, the grey line is straight while dashed red line is given curvature(rotation) at point B equal to -5.278(10^-4) rad.

请先登录,再进行评论。

回答(1 个)

Altaïr
Altaïr 2025-6-4
编辑:Altaïr 2025-6-4
To my understanding it seems like you are referring to the angular deflection at point B as curvature which is causing the confusion. I'll use the terminology, linear and angular displacements instead to keep things clear.
Lets say we have shape which can be defined by two line, as in the query:
% Original Shape
x=[0;6;12]; %% x coordinates of [A,B,C]
y=[0;4.5;4.5]; %% y coordinates of [A,B,C]
plot(x,y,'g') %% plotting
From a structural perspective, when the point B corresponds to a hinge joint (AB can move freely with respect to BC and vice versa) and undergoes only linear displacement. The new shape can be plotted by simply updating the coordinates of B.
Now lets say the beams AB and BC are rigidly fixed to each other (lets say by welding) and point B undergoes linear and/or angular displacement, the displacement values would vary continuously along the shape. The displacement equation would have to be determined through structural analysis. There are few different methods that one can adopt such as:
  1. Double-integration method
  2. Area-moment method
  3. Strain-energy method (Castigliano's Theorem)
  4. Conjugate-beam method
  5. Method of superposition
For simple, less-accurate visualization you can use hermite cubic interpolation to determine the displacements at different point along the beams. Here's an example in MATLAB where the same deflection values are assume for point B as in your query:
% Original points
x_orig = [0; 6; 12];
y_orig = [0; 4.5; 4.5];
% Deflected points
x_def = [0; 6.46; 12];
y_def = [0; 2.71; 4.5];
% Rotation at B (radians)
theta = -5.278e-4;
% Calculate segment lengths
d_AB = norm([x_def(2)-x_def(1), y_def(2)-y_def(1)]);
d_BC = norm([x_def(3)-x_def(2), y_def(3)-y_def(2)]);
% Original segment lengths
d_AB_orig = norm([6, 4.5]);
d_BC_orig = norm([6, 0]);
% Tangent at A (same direction as original AB)
T_A = (d_AB/d_AB_orig) * [6, 4.5];
% Rotation matrix
R = [cos(theta), -sin(theta);
sin(theta), cos(theta)];
% Tangent at B for AB segment (original direction rotated)
T_AB_orig = [6; 4.5]/d_AB_orig; % Unit vector AB
T_AB_rot = R * T_AB_orig; % Rotated unit vector
T_B_AB = d_AB * T_AB_rot'; % Scaled tangent vector
% Tangent at B for BC segment (original direction rotated)
T_BC_orig = [6; 0]/d_BC_orig; % Unit vector BC
T_BC_rot = R * T_BC_orig; % Rotated unit vector
T_B_BC = d_BC * T_BC_rot'; % Scaled tangent vector
% Tangent at C (same direction as original BC)
T_C = [d_BC, 0];
% Hermite interpolation parameters
t = linspace(0, 1, 100)';
% Calculate Hermite basis functions
h00 = 2*t.^3 - 3*t.^2 + 1;
h10 = t.^3 - 2*t.^2 + t;
h01 = -2*t.^3 + 3*t.^2;
h11 = t.^3 - t.^2;
% Segment AB: A to B
x1 = h00*x_def(1) + h10*T_A(1) + h01*x_def(2) + h11*T_B_AB(1);
y1 = h00*y_def(1) + h10*T_A(2) + h01*y_def(2) + h11*T_B_AB(2);
% Segment BC: B to C
x2 = h00*x_def(2) + h10*T_B_BC(1) + h01*x_def(3) + h11*T_C(1);
y2 = h00*y_def(2) + h10*T_B_BC(2) + h01*y_def(3) + h11*T_C(2);
% Plot results
figure;
hold on;
grid on;
% Original shape (green solid line)
plot(x_orig, y_orig, 'g-', 'LineWidth', 2);
% Deflected shape (red dashed line)
plot(x1, y1, 'r--', 'LineWidth', 2);
plot(x2, y2, 'r--', 'LineWidth', 2);
% Points
plot(x_orig, y_orig, 'ko', 'MarkerSize', 8, 'MarkerFaceColor', 'k');
plot(x_def, y_def, 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r');
legend('Original Shape', 'Deflected Shape', 'Location', 'best');
title('Structure Deflection with Consistent Angle at B');
xlabel('X-coordinate');
ylabel('Y-coordinate');
axis equal;
hold off;
There's a related function (pchip) in MATLAB that you can look into. Use the following command to access its documentation:
doc pchip

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by