Giter VIP home page Giter VIP logo

Comments (5)

UnnamedMoose avatar UnnamedMoose commented on June 8, 2024 1

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

from basicbspline.jl.

UnnamedMoose avatar UnnamedMoose commented on June 8, 2024

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?

from basicbspline.jl.

hyrodium avatar hyrodium commented on June 8, 2024

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?

from basicbspline.jl.

UnnamedMoose avatar UnnamedMoose commented on June 8, 2024

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.

from basicbspline.jl.

hyrodium avatar hyrodium commented on June 8, 2024

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.

from basicbspline.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.