Definite integral of a piecewise function
5 views (last 30 days)
Show older comments
Hi everyone,
I would like to calculate the surface area of the B-spline surface spanned by these basis functions, and therefore need to do piecewise integration in two directions.
I have read the existing threads on related topics, such as this, but I cannot seem to make it work.
See some of the code below, to get an idea of what I am trying to do:
%parametric variables
syms u v
%parametric functions in x, y and z, for parametric variables u and v
Rx= sum(sum(squeeze(Nu(1:nknots_u-1-(ku-1),ku))'*X*squeeze(Nv(1:nknots_v-1-(kv-1),kv))),2);
Ry= sum(sum(squeeze(Nu(1:nknots_u-1-(ku-1),ku))'*Y*squeeze(Nv(1:nknots_v-1-(kv-1),kv))),2);
Rz= sum(sum(squeeze(Nu(1:nknots_u-1-(ku-1),ku))'*Z*squeeze(Nv(1:nknots_v-1-(kv-1),kv))),2);
%parametric surface
S=[Rx,Ry,Rz];
%tangent plane
r_u=diff(S,u);
r_v=diff(S,v);
% surface normal
normal=cross(transpose(r_u),transpose(r_v));
% magnitude of normal
magn_normal=norm(normal);
f2=norm(cross(transpose(r_u),transpose(r_v)));
%vector of u in which ranges are defined.
% For example, Rx is defined differently for u in [1, -2/3), [-2/3, -1/3),...,[2/3, 1]
uu=[-1, -2/3, -1/3, 0, 1/3, 2/3, 1];
u_min=[-1, -2/3, -1/3, 0, 1/3, 2/3];
u_max=[-2/3, -1/3, 0, 1/3, 2/3, 1];
% Equivalently in v
vv=[-1 0 1];
v_min=[-1 0];
v_max=[0 1];
for iu=1:size(u_min,1)
for iv=1:size(v_min,1)
intu = int(f2, u, u_min(iu),u_max(iu));
intv(iu,iv) = int(intu, v, v_min(iv),v_max(iv));
end
end
The result of this for intv is however again a piecewise symbolic function. If I try to use subs(subs(intv,v,-1) ,u,-1), for example, I still cannot get a number as a result.
So two questions,
- Is there a way to analyse the piecewise function to obtain the function which applies for a certain range separately. Something like f2(-1<=u<-2/3), so that I can save each of these functions separately and integrate separately for each range?
- How can you otherwise get a definite integral for a piecewise function? I have also tried integral2 but according to the error description piecewise functions cannot be used as anonymous functions?
I would appreciate any help, ideas or tips.
All the Best,
Anna
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!