@@ -14,10 +14,10 @@ finite-difference approximation with step size `ε`.
1414- `ε`: step size to use for the finite-difference approximation
1515"""
1616function jacobian (
17- geometry,
18- ts;
17+ geometry:: G ,
18+ ts:: V ;
1919 ε = 1e-6
20- )
20+ ) where {G <: Meshes.Geometry , V <: Union{AbstractVector, Tuple} }
2121 T = eltype (ts)
2222
2323 # Get the partial derivative along the n'th axis via finite difference approximation
@@ -63,44 +63,11 @@ function jacobian(
6363 return map (∂ₙr, 1 : length (ts))
6464end
6565
66- """
67- differential(geometry, ts)
68-
69- Calculate the differential element (length, area, volume, etc) of the parametric
70- function for `geometry` at arguments `ts`.
71- """
72- function differential (
73- geometry,
74- ts
75- )
76- J = jacobian (geometry, ts)
77-
78- # TODO generalize this with geometric algebra, e.g.: norm(foldl(∧, J))
79- if length (J) == 1
80- return norm (J[1 ])
81- elseif length (J) == 2
82- return norm (J[1 ] × J[2 ])
83- elseif length (J) == 3
84- return abs ((J[1 ] × J[2 ]) ⋅ J[3 ])
85- else
86- error (" Not implemented yet. Please report this as an Issue on GitHub." )
87- end
88- end
89-
90- # ###############################################################################
91- # Partial Derivatives
92- # ###############################################################################
93-
94- """
95- derivative(b::BezierCurve, t)
96-
97- Determine the vector derivative of a Bezier curve `b` for the point on the
98- curve parameterized by value `t`.
99- """
100- function derivative (
66+ function jacobian (
10167 bz:: Meshes.BezierCurve ,
102- t
103- )
68+ ts:: V
69+ ) where {V <: Union{AbstractVector, Tuple} }
70+ t = only (ts)
10471 # Parameter t restricted to domain [0,1] by definition
10572 if t < 0 || t > 1
10673 throw (DomainError (t, " b(t) is not defined for t outside [0, 1]." ))
@@ -121,5 +88,35 @@ function derivative(
12188 # Derivative = N Σ_{i=0}^{N-1} sigma(i)
12289 # P indices adjusted for Julia 1-based array indexing
12390 sigma (i) = B (i, N - 1 )(t) .* (P[(i + 1 ) + 1 ] - P[(i) + 1 ])
124- return N .* sum (sigma, 0 : (N - 1 ))
91+ derivative = N .* sum (sigma, 0 : (N - 1 ))
92+
93+ return [derivative]
94+ end
95+
96+ # ###############################################################################
97+ # Differential Elements
98+ # ###############################################################################
99+
100+ """
101+ differential(geometry, ts)
102+
103+ Calculate the differential element (length, area, volume, etc) of the parametric
104+ function for `geometry` at arguments `ts`.
105+ """
106+ function differential (
107+ geometry:: G ,
108+ ts:: V
109+ ) where {G <: Meshes.Geometry , V <: Union{AbstractVector, Tuple} }
110+ J = jacobian (geometry, ts)
111+
112+ # TODO generalize this with geometric algebra, e.g.: norm(foldl(∧, J))
113+ if length (J) == 1
114+ return norm (J[1 ])
115+ elseif length (J) == 2
116+ return norm (J[1 ] × J[2 ])
117+ elseif length (J) == 3
118+ return abs ((J[1 ] × J[2 ]) ⋅ J[3 ])
119+ else
120+ error (" Not implemented yet. Please report this as an Issue on GitHub." )
121+ end
125122end
0 commit comments