How to plot streamlines on a 3D plane

5 views (last 30 days)
Gorkem Guclu
Gorkem Guclu on 16 Dec 2021
Answered: Nirupama on 1 Mar 2024
Hello everyone,
I have a 3D flow data on MATLAB. I created three 3D planes that are orthogonal each other and would like to plot streamlines on this plane. These three planes are not perpendicular to the original coordinate system of the domain. They have an angle. Is there a way to do that?
I put an image to make it clear. I would like to plot streamlines on the blue plane in the rectengular domain.
Thanks,
Gorkem
  2 Comments
Matt J
Matt J on 16 Dec 2021
Isn't a streamline a 3D space curve? What does it mean to plot a streamline "on" a plane?
Gorkem Guclu
Gorkem Guclu on 16 Dec 2021
Well, technically true. What I did is I took the projection of each velocity vector on the plane I specified. So I would like to plot them as a streamline, not as vectors.

Sign in to comment.

Answers (1)

Nirupama
Nirupama on 1 Mar 2024
I believe you would like to know how to plot streamlines on a 3D plane that is not aligned with the coordinate axes.
This requires a few steps to ensure that the streamlines are correctly calculated and displayed on the skewed planes.
I shall share a high level approach, you can customize based on your use case:
  • Define the Planes: You need the equations for the planes or a set of points that define the planes. Suppose you have the normal vectors and points on the planes, you can define the planes as follows:
% Normal vectors of the planes
normal1 = [nx1, ny1, nz1];
normal2 = [nx2, ny2, nz2];
normal3 = [nx3, ny3, nz3];
% Points on the planes
point1 = [px1, py1, pz1];
point2 = [px2, py2, pz2];
point3 = [px3, py3, pz3];
  • Intersect the Flow Field with the Planes: You need to calculate the intersection of your flow field with these planes to get the flow data on the planes.
  • Interpolate the Flow Data: Once you have the intersection points, you can interpolate the flow data onto these points. Assume you have the flow data in the form of velocity components U, V, and W, and you have a meshgrid of points X, Y, and Z where these velocities are defined. You can use "interp3" to interpolate the velocities onto the plane:
% Define a grid on the plane (you need to define gridX, gridY, gridZ based on the plane equation)
[planeX, planeY] = meshgrid(linspace(minX, maxX, numPoints), linspace(minY, maxY, numPoints));
planeZ = ... % Calculate Z based on the plane equation
% Interpolate the velocities onto the plane
planeU = interp3(X, Y, Z, U, planeX, planeY, planeZ);
planeV = interp3(X, Y, Z, V, planeX, planeY, planeZ);
planeW = interp3(X, Y, Z, W, planeX, planeY, planeZ);
  • Plot the Streamlines: Use the interpolated data to plot the streamlines on the planes. You can plot the streamlines on the plane using the "streamline" function:
% Starting points for streamlines (you need to define these)
startPoints = ... % [startX, startY, startZ]
% Plot the streamlines on the plane
streamline(planeX, planeY, planeZ, planeU, planeV, planeW, startPoints(:,1), startPoints(:,2), startPoints(:,3));
% Adjust view, axis, etc. as needed
view(3);
axis tight;
grid on;
For more details you can refer to the following documentation links:
Hope this helps!

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!