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

More plotting recipes #370

Merged
merged 18 commits into from
Feb 4, 2024
Merged

More plotting recipes #370

merged 18 commits into from
Feb 4, 2024

Conversation

hyrodium
Copy link
Owner

@hyrodium hyrodium commented Feb 4, 2024

This PR fixes #203.

julia> using StaticArrays, BasicBSpline, BasicBSplineFitting, Plots, Rotations

julia> plotly()
Plots.PlotlyBackend()

julia> f(u,v,w) = SVector(Angle2d(w)*SVector(u,v)..., w)
f (generic function with 1 method)

julia> P1 = P2 = BSplineSpace{3}(KnotVector([0,0,0,0,1,1,1,1]))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([0, 0, 0, 0, 1, 1, 1, 1]))

julia> P3 = BSplineSpace{3}(KnotVector([0,0,0,0,1,2,3,4,5,6,6,6,6]))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 6, 6, 6]))

julia> a = fittingcontrolpoints(f, P1, P2, P3);

julia> M = BSplineManifold(a, P1, P2, P3);

julia> plot(M; controlpoints=(;markersize=1))
Peek.2024-02-04.20-05.mp4

Copy link

codecov bot commented Feb 4, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (7fc8de3) 96.23% compared to head (db8892e) 96.39%.

Files Patch % Lines
ext/BasicBSplineRecipesBaseExt.jl 96.46% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #370      +/-   ##
==========================================
+ Coverage   96.23%   96.39%   +0.15%     
==========================================
  Files          14       14              
  Lines        1859     2023     +164     
==========================================
+ Hits         1789     1950     +161     
- Misses         70       73       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 4, 2024

julia> using StaticArrays, BasicBSpline, BasicBSplineFitting, Plots, Rotations

julia> k = knotvector"112111113111111121114"
KnotVector([1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 21, 21, 21])

julia> P = BSplineSpace{3}(k)
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 21, 21, 21]))

julia> plot(P; label="B-spline basis"); plot!(k; label="knot vector")

image

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 4, 2024

julia> using StaticArrays, BasicBSpline, BasicBSplineFitting, Plots, Rotations

julia> k1 = KnotVector(1:8)
KnotVector([1, 2, 3, 4, 5, 6, 7, 8])

julia> k2 = KnotVector(1:10)
KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

julia> P1 = BSplineSpace{2}(k1)
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8]))

julia> P2 = BSplineSpace{2}(k2)
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

julia> n1 = dim(P1)
5

julia> n2 = dim(P2)
7

julia> a = [SVector(i+j/2-cos(i-j)/5, j-i/2+sin(i+j)/5) for i in 1:n1, j in 1:n2]
5×7 Matrix{SVector{2, Float64}}:
 [1.3, 0.681859]      [1.89194, 1.52822]     [2.58323, 2.34864]   [3.198, 3.30822]    [3.63073, 4.44412]  [3.94327, 5.6314]   [4.30797, 6.69787]
 [2.39194, 0.028224]  [2.8, 0.84864]         [3.39194, 1.80822]   [4.08323, 2.94412]  [4.698, 4.1314]     [5.13073, 5.19787]  [5.44327, 6.08242]
 [3.58323, -0.65136]  [3.89194, 0.308215]    [4.3, 1.44412]       [4.89194, 2.6314]   [5.58323, 3.69787]  [6.198, 4.58242]    [6.63073, 5.3912]
 [4.698, -1.19178]    [5.08323, -0.0558831]  [5.39194, 1.1314]    [5.8, 2.19787]      [6.39194, 3.08242]  [7.08323, 3.8912]   [7.698, 4.8]
 [5.63073, -1.55588]  [6.198, -0.368603]     [6.58323, 0.697872]  [6.89194, 1.58242]  [7.3, 2.3912]       [7.89194, 3.3]      [8.58323, 4.39269]

julia> M = BSplineManifold(a,(P1,P2))
BSplineManifold{2, (2, 2), SVector{2, Float64}, Int64, Tuple{BSplineSpace{2, Int64, KnotVector{Int64}}, BSplineSpace{2, Int64, KnotVector{Int64}}}}(SVector{2, Float64}[[1.3, 0.6818594853651363] [1.891939538826372, 1.5282240016119735]  [3.9432675629073546, 5.6313973197437575] [4.307965942669926, 6.697871649324676]; [2.3919395388263722, 0.028224001611973443] [2.8, 0.8486395009384143]  [5.130728724172722, 5.197871649324676] [5.443267562907355, 6.082423697048351];  ; [4.697998499320089, -1.1917848549326278] [5.083229367309428, -0.055883099639785175]  [7.083229367309428, 3.891195777822126] [7.697998499320089, 4.800001958689859]; [5.630728724172722, -1.5558830996397852] [6.197998499320089, -0.3686026802562422]  [7.891939538826372, 3.3000019586898595] [8.583229367309428, 4.392685416399913]], (BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8])), BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))))

julia> plot(M)

image

@hyrodium
Copy link
Owner Author

hyrodium commented Feb 4, 2024

Document updates will be done in another PR.

@hyrodium hyrodium merged commit 40d3387 into main Feb 4, 2024
12 of 13 checks passed
@hyrodium hyrodium deleted the feature/more_recipes branch February 5, 2024 06:29
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.

Add more plotting recipes
1 participant