Skip to content

Improve CairoMakie pdf output #224

@1-Bart-1

Description

@1-Bart-1

Currently the 3d plots output by CairoMakie is bad because of the dense meshes.
Flat arrows should be used instead:

"""Flat 2D arrow in 3D: line shaft + triangular mesh head."""
function arrow_flat!(
    ax, origin, direction, tip_width, tip_length,
    plane_normal; color=:black, linewidth=2,
)
    o = collect(Float64, origin)
    d = collect(Float64, direction)
    pn = collect(Float64, plane_normal)
    dir = normalize(d)
    len = norm(d)
    shaft_end = o + (len - tip_length) * dir
    tip_apex = o + len * dir

    perp = cross(dir, pn)
    if norm(perp) < 1e-6
        perp = abs(dir[3]) < 0.9 ?
            cross(dir, [0.0, 0.0, 1.0]) :
            cross(dir, [1.0, 0.0, 0.0])
    end
    perp = normalize(perp) * tip_width

    shaft_vis = o + (len - tip_length * 0.7) * dir
    lines!(ax,
        [Point3f(o...), Point3f(shaft_vis...)],
        color=color, linewidth=linewidth)
    tri = [
        Point3f((shaft_end - perp)...),
        Point3f((shaft_end + perp)...),
        Point3f(tip_apex...),
    ]
    mesh!(ax, tri, [1 2 3], color=color, shading=NoShading)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions