Line data Source code
1 : import .BarycentricCoordinates: baryint, mapbarycoords, barycoords
2 :
3 1 : baryint(x::Attribute{T, VHnd}, a::VHnd, b::VHnd) where{T} =
4 : baryint(x[a], x[b])
5 :
6 1 : baryint(x::Attribute{T, VHnd}, a::VHnd, b::VHnd, c::VHnd) where{T} =
7 : baryint(x[a], x[b], x[c])
8 :
9 5 : baryint(x::Attribute{T, VHnd}, abc) where{T} = baryint(x[abc]...)
10 :
11 : # from triangles
12 :
13 2 : baryint(mesh::Mesh, x::Attribute{T, VHnd}, f::FHnd) where {T} =
14 : baryint(x, triangle(mesh, f))
15 :
16 1 : baryint(mesh::Mesh, x, f::FHnd) =
17 : baryint(vattr(mesh, x), triangle(mesh, f))
18 :
19 1 : baryint(g::AbstractGeometry, x, f::FHnd) =
20 : baryint(g::AbstractGeometry, x, f::FHnd, _istriangulation(g))
21 :
22 1 : baryint(g::AbstractGeometry, x, f::FHnd, ::IsTriangulation) =
23 : baryint(tessellation(g), x, f)
24 :
25 : # from half-edges
26 :
27 2 : baryint(mesh::Mesh, x::Attribute{T, VHnd}, h::HHnd) where {T} =
28 : baryint(x, vertices(mesh, h))
29 :
30 1 : baryint(g::AbstractGeometry, x, h::HHnd) = baryint(tessellation(g), x, h)
31 :
32 : """
33 : b = baryint(a, b)
34 : b = baryint(a, b, c)
35 : b = baryint((a, b, c))
36 :
37 : x = vattr(mesh, Val(:x))
38 :
39 : b = baryint(x, v1, v2) # vertex handles
40 : b = baryint(x, v1, v2, v3)
41 :
42 : b = baryint(Val(:x), ...)
43 :
44 : b = baryint(mesh, x, h) # vertices of half-edge h
45 : b = baryint(mesh, x, f) # vertices of triangular face f
46 :
47 : g = triangulated(geometry(mesh, ...))
48 :
49 : b = bayrint(g, x, h)
50 : b = bayrint(g, x, f)
51 :
52 : Creates a callable object `b` for barycentric interpolation between 2
53 : (e.g., algong half-edge) or 3 (e.g., in triangle) values, typically
54 : given by a vertex attribute.
55 :
56 : `b` can be evaluated at barycentric coordinates `λ` with `sum(λ) == 1`
57 :
58 : λ = SVector(λ₁, λ₂)
59 :
60 : y = b(λ)
61 : y = b(λ₁, λ₂)
62 :
63 : λ = SVector(λ₁, λ₂, λ₃)
64 :
65 : y = b(λ)
66 : y = b(λ₁, λ₂, λ₃)
67 :
68 :
69 : where `λ` is an `SVector` or `NTuple` of length 2 or 3.
70 :
71 : See also [`geometry`](@ref)
72 : """ baryint
|