Skip to content

Commit

Permalink
Update docs (#380)
Browse files Browse the repository at this point in the history
* update docs

* remove dot

* remove geometric modeling page

* update fitting page

* remove plots.jl page
  • Loading branch information
hyrodium authored Feb 10, 2024
1 parent 4018147 commit 15c1dee
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 277 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Basic (mathematical) operations for B-spline functions and related things with J
[![Coverage](https://codecov.io/gh/hyrodium/BasicBSpline.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/hyrodium/BasicBSpline.jl)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![DOI](https://zenodo.org/badge/258791290.svg)](https://zenodo.org/badge/latestdoi/258791290)
[![BasicBSpline Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/BasicBSpline)](https://pkgs.genieframework.com?packages=BasicBSpline).
[![BasicBSpline Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/BasicBSpline)](https://pkgs.genieframework.com?packages=BasicBSpline)

![](docs/src/img/BasicBSplineLogo.png)

Expand Down
2 changes: 0 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ makedocs(;
# "ChainRules" => "chainrules.md"
# ],
"Visualization" => [
"Plots.jl" => "visualization/plots.md",
"PlotlyJS.jl" => "visualization/plotlyjs.md",
"BasicBSplineExporter.jl" => "visualization/basicbsplineexporter.md",
],
"Geometric modeling" => "geometricmodeling.md",
"Interpolations" => "interpolations.md",
"API" => "api.md",
],
Expand Down
1 change: 1 addition & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ isdegenerate(P::BSplineSpace)
BSplineManifold
unbounded_mapping
RationalBSplineManifold
fittingcontrolpoints
```

```@docs
Expand Down
101 changes: 0 additions & 101 deletions docs/src/geometricmodeling.md

This file was deleted.

7 changes: 3 additions & 4 deletions docs/src/math/bsplinebasis.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ end
Let ``X_1, \dots, X_n`` be i.i.d. random variables with ``X_i \sim U(0,1)``, then the probability density function of ``X_1+\cdots+X_n`` can be obtained via `BasicBSpline.uniform_bsplinebasis_kernel(Val(n-1),t)`.

```@example math_bsplinebasis
gr()
N = 100000
# polynomial degree 0
plot1 = histogram([rand() for _ in 1:N], normalize=true, label=false)
Expand All @@ -289,10 +290,8 @@ plot4 = histogram([rand()+rand()+rand()+rand() for _ in 1:N], normalize=true, la
plot!(t->BasicBSpline.uniform_bsplinebasis_kernel(Val(3),t), label=false)
# plot all
plot(plot1,plot2,plot3,plot4)
savefig("histogram-uniform.html") # hide
savefig("histogram-uniform.png") # hide
nothing # hide
```

```@raw html
<object type="text/html" data="../histogram-uniform.html" style="width:100%;height:420px;"></object>
```
![](histogram-uniform.png)
61 changes: 49 additions & 12 deletions docs/src/math/fitting.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# Fitting with B-spline manifold

The following functions such as `fittingcontolpoints` were provided from BasicBSpline.jl before v0.9.0.
From BasicBSpline v0.9.0, these functions are moved to [BasicBSplineFitting](https://github.com/hyrodium/BasicBSplineFitting.jl).

```@setup math
## Setup
```@example math_fitting
using BasicBSpline
using BasicBSplineFitting
using BasicBSplineExporter
using StaticArrays
using Plots; plotly()
using Plots
```

Fitting with least squares method.
## Fitting with least squares

```@docs
fittingcontrolpoints
```
[`fittingcontrolpoints`](@ref) function

```@example math
```@example math_fitting
p1 = 2
p2 = 2
k1 = KnotVector(-10:10)+p1*KnotVector([-10,10])
Expand All @@ -29,9 +24,51 @@ f(u1, u2) = SVector(2u1 + sin(u1) + cos(u2) + u2 / 2, 3u2 + sin(u2) + sin(u1) /
a = fittingcontrolpoints(f, (P1, P2))
M = BSplineManifold(a, (P1, P2))
save_png("fitting.png", M, unitlength=50, xlims=(-10,10), ylims=(-10,10))
gr()
plot(M; xlims=(-10,10), ylims=(-10,10), aspectratio=1)
savefig("fitting.png") # hide
nothing # hide
```
![](fitting.png)

[Try on Desmos graphing graphing calculator!](https://www.desmos.com/calculator/2hm3b1fbdf)
![](../img/fitting_desmos.png)


### Cardioid (planar curve)
```@example math_fitting
f(t) = SVector((1+cos(t))*cos(t),(1+cos(t))*sin(t))
p = 3
k = KnotVector(range(0,2π,15)) + p * KnotVector([0,2π]) + 2 * KnotVector([π])
P = BSplineSpace{p}(k)
a = fittingcontrolpoints(f, P)
M = BSplineManifold(a, P)
gr()
plot(M; aspectratio=1)
savefig("plots-cardioid.html") # hide
nothing # hide
```

```@raw html
<object type="text/html" data="../plots-cardioid.html" style="width:100%;height:550px;"></object>
```

### Helix (spatial curve)
```@example math_fitting
f(t) = SVector(cos(t),sin(t),t)
p = 3
k = KnotVector(range(0,6π,15)) + p * KnotVector([0,6π])
P = BSplineSpace{p}(k)
a = fittingcontrolpoints(f, P)
M = BSplineManifold(a, P)
plotly()
plot(M)
savefig("plots-helix.html") # hide
nothing # hide
```

```@raw html
<object type="text/html" data="../plots-helix.html" style="width:100%;height:550px;"></object>
```
3 changes: 2 additions & 1 deletion docs/src/math/rationalbsplinemanifold.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ t = 1 # angle in radians
a = [SVector(1,0), SVector(1,tan(t/2)), SVector(cos(t),sin(t))]
w = [1,cos(t/2),1]
M = RationalBSplineManifold(a,w,P)
plot(M, xlims=(0,1.1), ylims=(0,1.1), aspectratio=1)
plot([cosd(t) for t in 0:360], [sind(t) for t in 0:360]; xlims=(-1.1,1.1), ylims=(-1.1,1.1), aspectratio=1, label="circle", color=:gray, linestyle=:dash)
plot!(M; label="Rational B-spline curve")
savefig("geometricmodeling-arc.png") # hide
nothing # hide
```
Expand Down
Loading

0 comments on commit 15c1dee

Please sign in to comment.