3D integration over a region bounded by some planes.
I want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
endI want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
end I want to perform 3D integrations of some functions over a region defined by the following 16 planes. As an example, consider the function . The region is bounded by:
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
2 planes parallel to -plane at and .
8 planes which are penpendicular to the vectors – given in below code at mid point of these vector ().
Code to visulize the last 8 planes. First 8 planes are quite eays to imagine.
clear; clc;
figure; hold on;
axis([-1 1 -1 1 -1 1])
% function to calculate the 8 vectors:
f = @(vec) vec(1)*[-1 1 1] + vec(2)*[1 -1 1] + vec(3)*[1 1 -1];
% 8 vectors:
v1 = f([1, 1, 1]);
v2 = f([-1, -1, -1]);
v3 = f([0, 1, 0]);
v4 = f([0, -1, 0]);
v5 = f([0, 0, 1]);
v6 = f([0, 0, -1]);
v7 = f([1, 0, 0]);
v8 = f([-1, 0, 0]);
% draw planes perpendicular to v vectors at v/2 point:
draw_plane(v1)
draw_plane(v2)
draw_plane(v3)
draw_plane(v4)
draw_plane(v5)
draw_plane(v6)
draw_plane(v7)
draw_plane(v8)
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
box on;
set(gca,’fontname’,’times’,’fontsize’,16)
view([-21 19])
hold off;
function [] = draw_plane(v)
% I took this algorithem from ChatGPT to draw a plane perpendicular to v
plane_size = 3;
midpoint = v./2;
normal_vector = v / norm(v);
perpendicular_vectors = null(normal_vector)’;
[t1, t2] = meshgrid(linspace(-plane_size, plane_size, 100));
plane_points = midpoint + t1(:) * perpendicular_vectors(1,:) + t2(:) * perpendicular_vectors(2,:);
X = reshape(plane_points(:,1), size(t1));
Y = reshape(plane_points(:,2), size(t1));
Z = reshape(plane_points(:,3), size(t1));
surf(X, Y, Z, ‘FaceAlpha’, 0.5, ‘EdgeColor’, ‘none’);
plot3(midpoint(1), midpoint(2), midpoint(3), ‘go’, ‘MarkerSize’, 10, ‘MarkerFaceColor’, ‘g’);
text(midpoint(1), midpoint(2), midpoint(3), [‘(‘,num2str(v(1)),’,’,num2str(v(2)),’,’,num2str(v(3)),’)’]);
end integral, integration, numerical integration MATLAB Answers — New Questions