-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumIntTriangle.m
More file actions
23 lines (17 loc) · 789 Bytes
/
numIntTriangle.m
File metadata and controls
23 lines (17 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [val] = numIntTriangle(funcIn, TriangleVertices, quadratureParameters)
% This function uses the quadrature rule on the unit triangle for numerical integration
%
% f ... function to be integrated
% TriangleVertices ... vertices of triangle
% quadratureParameters ... weights and evaluation points for gaussian
% quadrature on the unit triangle
% the baricentric points are transformed from the unit triangle to the
% actual reference triangle element
transformMatrix = getTransformationMatrix(TriangleVertices);
[X,Y] = transformFromUnitTriangle(quadratureParameters.Points, TriangleVertices);
fvals = zeros(size(X,1),1);
for i=1:size(X,1)
fvals(i) = feval(funcIn,X(i),Y(i));
end
val = quadratureParameters.W' * fvals* det(transformMatrix);
end