Intersection between plane and function (3d)

2 ビュー (過去 30 日間)
Frida Andersson
Frida Andersson 2022 年 1 月 6 日
回答済み: Kartik Saxena 2023 年 11 月 28 日
I need help with how to go by to find the intersection point between the "plane" and functions, these different functions describe a throw parable on the earth, with and without magnus force. The plane is supposed to represent the floor, and my thought is that I should be able to get the throw width by calculation the intersection point where the function goes trough the plane. But i'm not sure how to do it, i've tried some different methods without any luck. What is the best way to calculate the throw width?
Parameters
clearvars, clc
C = 0.5; % Factors like Reynolds etc.
r = 0.037; % Radius baseball in [m]
A = r^2*pi; % Cross-sectional area ball in [m^2]
m = 0.143; % Mass baseball in [kg]
rho = 1.25; % Density of air earth in [kg/m^3]
g = 9.81; % Gravity acceleration on jorden in [m/s^2]
F = (C*A*rho)/(2*m);
s = 6*10^-5;
w = [4*pi 900 4*pi]; % Angular velocity
pv = [0 16 0 10 0 16];
Calculations
[t,wp]=ode45(@(t,x)kast(t,x,F,g),[0 20],pv);
plot3(wp(:,1),wp(:,3),wp(:,5),'k-',LineWidth=2)
[t,op]=ode45(@(t,x)kastmag(t,x,F,g),[0 20],pv);
hold on
plot3(op(:,1),op(:,3),op(:,5),'r-',LineWidth=2)
ax = gca;
mesh(linspace(2*ax.XLim(1),2*ax.XLim(2),100),linspace(2*ax.YLim(1),2*ax.YLim(2),100),zeros(100));
axis([0 45 0 40 0 15]);
title('Throw parable baseball earth');xlabel('x');ylabel('y');zlabel('z');
legend('Throwparable without Magnuseffect','Throwparable with Magnuseffect','Floor')
grid on
view([7 9])
Functions
function [dx] = kast(t,x,F,g)
dx=zeros(4,1);
dx(1) = x(2);
dx(2) = -F.*x(2).*sqrt(x(2).^2+x(4).^2+x(6).^2);
dx(3) = x(4);
dx(4) = -F.*x(4).*sqrt(x(2).^2+x(4).^2+x(6).^2);
dx(5) = x(6);
dx(6) = -g -F.*x(6).*sqrt(x(2).^2+x(4).^2+x(6).^2);
end
function mag = magnus(pv,w,s,m)
mag = (s)*cross(w,[pv(2) pv(4) pv(6)]);
end
function [dx] = kastmag(t,x,F,g)
pv = [0 16 0 10 1.7 16];
w = [4*pi 900 4*pi];
s = 6*10^-5;
m = 0.143;
M = magnus(pv,w,s,m);
dx=zeros(4,1);
dx(1) = x(2);
dx(2) = -F.*x(2).*sqrt(x(2).^2+x(4).^2+x(6).^2)+M(1);
dx(3) = x(4);
dx(4) = -F.*x(4).*sqrt(x(2).^2+x(4).^2+x(6).^2)+M(2);
dx(5) = x(6);
dx(6) = -g -F.*x(6).*sqrt(x(2).^2+x(4).^2+x(6).^2)+M(3);
end

回答 (1 件)

Kartik Saxena
Kartik Saxena 2023 年 11 月 28 日
Hi,
I understand that you want to calculate the throw width by calculating the distance between two intersection points of the function with the plane.
To find the intersection point between the trajectory of a thrown baseball and the plane representing the floor, you need to determine the point at which the z-coordinate of the trajectory (representing the height above the floor) becomes zero. This is essentially finding the roots of the z-coordinate function of time.
Since you're using 'ode45' to solve the differential equations that describe the motion of the baseball, you can use MATLAB's event detection feature to stop the integration as soon as the z-coordinate becomes zero. This is done by defining an events function that tracks when the z-coordinate crosses zero.
Refer to the following MathWorks documentation for detailed information about "ODE Event Location":
I hope this resolves your issue.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by