Cross Product to calculate Surface area
1 view (last 30 days)
Show older comments
Ok. I have figure data(it has a lot of interpolating planets connected but when I use this method: ... no matter what the data in x, y, z... or figure it always bing up same number 113...ect.. kind a thinking it doesn't work with a direct input data or any figures.. help please.. cross product in order to correspond to my cartesian data or 3d interpolating surface figures..
[x,y,z] = peaks;
[m,n] = size(z);
area = 0; for i = 1:m-1 for j = 1:n-1 v0 = [x(i,j) y(i,j) z(i,j) ]; v1 = [x(i,j+1) y(i,j+1) z(i,j+1) ]; v2 = [x(i+1,j) y(i+1,j) z(i+1,j) ]; v3 = [x(i+1,j+1) y(i+1,j+1) z(i+1,j+1)];
a = v1 - v0; b = v2 - v0; c = v3 - v0;
A = 1/2*(norm(cross(a, c)) + norm(cross(b, c))); area = area + A; end end
fprintf('\nTotal area is: %f\n\n', area);
0 Comments
Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!