Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation #373

Merged
merged 11 commits into from
Feb 6, 2024
Merged

Update documentation #373

merged 11 commits into from
Feb 6, 2024

Conversation

hyrodium
Copy link
Owner

@hyrodium hyrodium commented Feb 5, 2024

No description provided.

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 5, 2024

TODO

  • Update README documentation
  • Update API page
  • Update plotting examples

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 5, 2024

Plotting example

using BasicBSpline
using Plots
using Random

# Initialize
gr()
Random.seed!(42)
N = 10

# Easing functions
c=2/√3
f(t) = ifelse(t>0,exp(-1/t),0.0)
g(t) = 1-f(c*t)/(f(c*t)+f(c-c*t))
h(t) = 1-f((1-t)/2)/f(1/2)

# Default knot vector
v = 10*(1:N-1)/N + randn(N-1)*0.5
pushfirst!(v,0)
push!(v,10)

anim = @animate for t in 0:0.05:5
    k = KnotVector(v)
    k.vector[4] = v[4]
    k.vector[5] = v[4] + (g(t-0) + ifelse(t>3.9,h(t-3.9),0)) * (v[5]-v[4])
    k.vector[6] = v[4] + (g(t-1) + ifelse(t>3.6,h(t-3.6),0)) * (v[6]-v[4])
    k.vector[7] = v[4] + (g(t-2) + ifelse(t>3.3,h(t-3.3),0)) * (v[7]-v[4])
    P0 = BSplineSpace{0}(k)
    P1 = BSplineSpace{1}(k)
    P2 = BSplineSpace{2}(k)
    P3 = BSplineSpace{3}(k)
    plot(
        plot(P0; label="P0", ylims=(0,1), color=palette(:cool,4)[1]),
        plot(P1; label="P1", ylims=(0,1), color=palette(:cool,4)[2]),
        plot(P2; label="P2", ylims=(0,1), color=palette(:cool,4)[3]),
        plot(P3; label="P3", ylims=(0,1), color=palette(:cool,4)[4]),
        plot(k; label="knot vector", ylims=(-0.1,0.1), color=:white);
        layout=(5,1),
        size=(501,800)
    )
end

run(`ffmpeg -y -framerate 24 -i $(anim.dir)/%06d.png -c:v libx264 -pix_fmt yuv420p output.mp4`)
output.mp4

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 5, 2024

Slightly updated

using BasicBSpline
using Plots
using Random

# Initialize
gr()
Random.seed!(42)
N = 10

# Easing functions
c=2/√3
f(t) = ifelse(t>0,exp(-1/t),0.0)
g(t) = 1-f(c*t)/(f(c*t)+f(c-c*t))
h(t) = 1-f((1-t)/2)/f(1/2)

# Default knot vector
v = 10*(1:N-1)/N + randn(N-1)*0.5
pushfirst!(v,0)
push!(v,10)

anim = @animate for t in 0:0.05:5
    k = KnotVector(v)
    k.vector[4] = v[4]
    k.vector[5] = v[4] + (g(t-0) + ifelse(t>3.9,h(t-3.9),0)) * (v[5]-v[4])
    k.vector[6] = v[4] + (g(t-1) + ifelse(t>3.6,h(t-3.6),0)) * (v[6]-v[4])
    k.vector[7] = v[4] + (g(t-2) + ifelse(t>3.3,h(t-3.3),0)) * (v[7]-v[4])
    P0 = BSplineSpace{0}(k)
    P1 = BSplineSpace{1}(k)
    P2 = BSplineSpace{2}(k)
    P3 = BSplineSpace{3}(k)
    plot(
        plot(P0; label="P0", ylims=(0,1), color=palette(:cool,4)[1]),
        plot(P1; label="P1", ylims=(0,1), color=palette(:cool,4)[2]),
        plot(P2; label="P2", ylims=(0,1), color=palette(:cool,4)[3]),
        plot(P3; label="P3", ylims=(0,1), color=palette(:cool,4)[4]),
        plot(k; label="knot vector", ylims=(-0.1,0.02), color=:white, yticks=nothing);
        layout=grid(5, 1, heights=[0.23 ,0.23, 0.23, 0.23, 0.08]),
        size=(501,800)
    )
end

run(`ffmpeg -y -framerate 24 -i $(anim.dir)/%06d.png -c:v libx264 -pix_fmt yuv420p output.mp4`)

@hyrodium hyrodium merged commit 6e16065 into main Feb 6, 2024
11 of 12 checks passed
@hyrodium hyrodium deleted the docs/update branch February 6, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant