LCOV - code coverage report
Current view: top level - src/geometry - maptriangles.jl (source / functions) Hit Total Coverage
Test: on branch (detached from b856613) Lines: 0 18 0.0 %
Date: 2025-12-02 13:19:26 Functions: 0 0 -

          Line data    Source code
       1           0 : linearmap2d(g::AbstractGeometry, f::FHnd) =
       2             :     _linearmap2d(g, _istriangulation(g), f)
       3             : 
       4           0 : function linearmap2d(g::AbstractGeometry)
       5           0 :     let g = g
       6           0 :         f -> _linearmap2d(g, _istriangulation(g), f)
       7             :     end
       8             : end
       9             : 
      10             : """
      11             :     g = triangulated(geometry(mesh, x, ...))
      12             :     A = linearmap2d(g, f)
      13             : 
      14             :     fA = linearmap2d(g)
      15             :     A = fa(f)
      16             : 
      17             : Construct linear map `A` as the 2×2 matrix that maps the standard
      18             : triangle `[0,0], [1,0], [0,1]` to a 2d triangle that is congruent
      19             : (with same orientation) to `f`.
      20             : 
      21             : !!! warning "precondition"
      22             :     This method requires a triangle mesh.
      23             : 
      24             : See also [`localframe`](@ref)
      25             : """ linearmap2d
      26             : 
      27             : # _linearmap2d(g, ::IsTriangulation, f::FHnd) = _linearmap2d(rawfacebase(g, f)...)
      28             : 
      29             : 
      30             : # _linearmap2d(g, ::IsTriangulation, f::FHnd) =
      31             : #     _linearmap2d(position(g)[triangle(tessellation(g), f)]...)
      32             : 
      33             : # NOTE: Zygote fails to differentiate the following expression (with "...")
      34             : #       Replace definition above by below.
      35             : 
      36           0 : function _linearmap2d(g, ::IsTriangulation, f::FHnd)
      37           0 :     i, j, k = triangle(tessellation(g), f)
      38           0 :     _linearmap2d(position(g)[i], position(g)[j], position(g)[k])
      39             : end
      40             : 
      41           0 : _linearmap2d(a, b, c) = _linearmap2d(b - a, c - a)
      42             : 
      43           0 : function _linearmap2d(a::SVector{2, T}, b::SVector{2, T}) where {T}
      44           0 :     [ a b ] :: SMatrix{2, 2, T, 4}
      45             : end
      46             : 
      47           0 : function _linearmap2d(a::SVector{3, T}, b::SVector{3, T}) where {T}
      48           0 :     norma = norm(a)
      49           0 :     u = a / norma
      50           0 :     nrm = normalize(u × b)
      51           0 :     v = normalize(nrm × u) # works w/o normalize up to rounding
      52             : 
      53           0 :     a2 = SA[ norma, 0 ]
      54           0 :     b2 = SA[ dot(b, u), dot(b, v) ]
      55             : 
      56           0 :     [ a2 b2 ] :: SMatrix{2, 2, T, 4}
      57             : end
      58             : 
      59             : # TODO: linearmap3d
      60             : 
      61             : # TODO: linearmap2d from arbitrary 2d / 3d triangle (compose)

Generated by: LCOV version 1.16