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

Add more documentation #150

Open
7 of 10 tasks
hyrodium opened this issue Jan 26, 2022 · 5 comments
Open
7 of 10 tasks

Add more documentation #150

hyrodium opened this issue Jan 26, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@hyrodium
Copy link
Owner

hyrodium commented Jan 26, 2022

TODO:

  • BSplineManifold vs CustomBSplineManifold
  • KnotVector vs UniformKnotVector
  • bsplinebasis vs bsplinebasisall
  • BSplineSpace vs UniformBSplineSpace
  • issubset vs issqsubset
  • bsplinebasis vs bsplinebasis₊₀ vs bsplinebasis₋₀
  • unsafe_* methods
  • bsplinebasis′
  • BSplineDerivativeSpace
  • Interactive examples with Makie.jl
@hyrodium hyrodium added the documentation Improvements or additions to documentation label Jan 30, 2022
@UnnamedMoose
Copy link

Hi, I have just come across your package and it seems exactly like what I need. Ultimately, I want to be able to compute the signed distance function from a spline. To do that, I need to evaluate the curve at specific s-parameter values. I am trying to understand how to do that from the code, but being new to Julia, I am progressing very slowly. Could you please point me to the right place?

@hyrodium
Copy link
Owner Author

Thank you for your interest in this package!

Ultimately, I want to be able to compute the signed distance function from a spline. To do that, I need to evaluate the curve at specific s-parameter values.

I'm not much familiar with s-parameter etc. Could you provide some math expressions or references for this?

@UnnamedMoose
Copy link

I just mean the non-dimensional length of the curve ranging from 0 to 1. For instance, in the NURBS.jl package you can do this:

evalpoints = collect(0:0.0005:1.0)
CBspline = curvePoints(NBspline, evalpoints)

However, that library seems to no longer be maintained and therefore I was hoping to use yours instead.

@hyrodium
Copy link
Owner Author

hyrodium commented Jun 1, 2023

Ah, I see. Here's a simple example:

julia> using StaticArrays, BasicBSpline

julia> k = KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])  # knot vector in parameter space
KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])

julia> P = BSplineSpace{2}(k)
BSplineSpace{2, Float64, KnotVector{Float64}}(KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0]))

julia> C = BSplineManifold([SVector(1,2), SVector(2,3), SVector(-2,2), SVector(-4,1)], P)
BSplineManifold{1, (2,), SVector{2, Int64}, Tuple{BSplineSpace{2, Float64, KnotVector{Float64}}}}((BSplineSpace{2, Float64, KnotVector{Float64}}(KnotVector([0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0])),), SVector{2, Int64}[[1, 2], [2, 3], [-2, 2], [-4, 1]])

julia> C.(0:0.1:1)
11-element Vector{SVector{2, Float64}}:
 [1.0, 2.0]
 [1.2800000000000002, 2.3400000000000007]
 [1.3199999999999998, 2.5600000000000005]
 [1.12, 2.6599999999999997]
 [0.6799999999999997, 2.6399999999999997]
 [0.0, 2.5]
 [-0.7999999999999996, 2.2800000000000002]
 [-1.5999999999999996, 2.0200000000000005]
 [-2.4000000000000004, 1.72]
 [-3.2, 1.38]
 [-4.0, 1.0]

An instance of BSplineManifold is callable, so you can just add arguments to that. Note that there is also unbounde_mapping function. This function extrapolate the manifold.

julia> unbounded_mapping.(C, 0:0.1:1)
11-element Vector{SVector{2, Float64}}:
 [1.0, 2.0]
 [1.2800000000000002, 2.3400000000000007]
 [1.3199999999999998, 2.5600000000000005]
 [1.12, 2.6599999999999997]
 [0.6799999999999997, 2.6399999999999997]
 [0.0, 2.5]
 [-0.7999999999999996, 2.2800000000000002]
 [-1.5999999999999996, 2.0200000000000005]
 [-2.4000000000000004, 1.72]
 [-3.2, 1.38]
 [-4.0, 1.0]

julia> unbounded_mapping.(C, -1)
2-element SVector{2, Float64} with indices SOneTo(2):
 -15.0
  -8.0

julia> C(-1)
ERROR: DomainError with -1:
The input -1 is out of range.
Stacktrace:
 [1] macro expansion
   @ ~/.julia/dev/BasicBSpline/src/_BSplineManifold.jl:146 [inlined]
 [2] (::BSplineManifold{1, (2,), SVector{2, Int64}, Tuple{BSplineSpace{2, Float64, KnotVector{Float64}}}})(t::Int64)
   @ BasicBSpline ~/.julia/dev/BasicBSpline/src/_BSplineManifold.jl:146
 [3] top-level scope
   @ REPL[26]:1

Please check the documentation for more information.

@UnnamedMoose
Copy link

Fantastic, this is exactly what I was looking for. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants