Skip to content

Commit

Permalink
Merge pull request #42 from jverzani/gh_pages
Browse files Browse the repository at this point in the history
use documenter for docs, asciigraph bug fix
  • Loading branch information
jverzani authored Apr 27, 2022
2 parents 7fdad77 + f18a359 commit ae434a5
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 175 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.0' # lowest supported version
- '1.0' # lowest supported version; though possibly with errors
- '1.6' # LTS support
- '1' # last released version
os:
- ubuntu-latest
Expand Down Expand Up @@ -45,25 +46,25 @@ jobs:
- uses: codecov/codecov-action@v1
with:
file: lcov.info
# docs:
# name: Documentation
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: julia-actions/setup-julia@v1
# with:
# version: '1'
# - run: |
# julia --project=docs -e '
# using Pkg
# Pkg.develop(PackageSpec(path=pwd()))
# Pkg.instantiate()'
# - run: |
# julia --project=docs -e '
# using Documenter: doctest
# using ImplicitEquations
# doctest(ImplicitEquations)'
# - run: julia --project=docs docs/make.jl
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: |
julia --project=docs -e '
using Documenter: doctest
using ImplicitEquations
doctest(ImplicitEquations)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
appveyor.yml
.travis.yml
Manifest.toml
*.jl.cov
*.jl.*.cov
*.jl.mem
docs/build
docs/site
docs/Manifest.toml
test/benchmarks.json
Manifest.toml
TODO.md
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ImplicitEquations"
uuid = "95701278-4526-5785-aba3-513cca398f19"
version = "1.0.7"
version = "1.0.8"

[deps]
CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50"
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[![Build Status](https://travis-ci.com/jverzani/ImplicitEquations.jl.svg?branch=master)](https://travis-ci.com/jverzani/ImplicitEquations.jl)

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://jverzani.github.io/ImplicitEquations.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://jverzani.github.io/ImplicitEquations.jl/dev)
[![Build Status](https://github.com/jverzani/ImplicitEquations.jl/workflows/CI/badge.svg)](https://github.com/jverzani/ImplicitEquations.jl/actions)
[![codecov](https://codecov.io/gh/jverzani/ImplicitEquations.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/jverzani/ImplicitEquations.jl)



# ImplicitEquations
Expand All @@ -12,20 +17,19 @@ the `Julia` user to naturally represent and easily render graphs of
implicit functions and equations.


We give one example, others may be viewed as an `IJulia` notebook ([here](http://nbviewer.ipython.org/github/jverzani/ImplicitEquations.jl/blob/master/docs/examples.ipynb)).
We give one example, others may be viewed in the documentation.

The
[Devils curve](http://www-groups.dcs.st-and.ac.uk/~history/Curves/Devils.html)
is graphed over the default region as follows:

```
using Plots
pyplot()
using ImplicitEquations
using Plots, ImplicitEquations
a,b = -1,2
f(x,y) = y^4 - x^4 + a*y^2 + b*x^2
plot(f ⩵ 0) # \Equal[tab]
plot(f ⩵ 0) # \Equal[tab] or Eq(f, 0)
```

![DevilsCurve](http://i.imgur.com/LChTzC1.png)
4 changes: 4 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
69 changes: 0 additions & 69 deletions docs/examples.ipynb

This file was deleted.

19 changes: 19 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Documenter
using ImplicitEquations


ENV["PLOTS_TEST"] = "true"
ENV["GKSwstype"] = "100"


DocMeta.setdocmeta!(ImplicitEquations, :DocTestSetup, :(using ImplicitEquations); recursive = true)

makedocs(
sitename = "ImplicitEquations",
format = Documenter.HTML(ansicolor=true),
modules = [ImplicitEquations]
)

deploydocs(
repo = "github.com/jverzani/ImplicitEquations.jl"
)
87 changes: 37 additions & 50 deletions docs/examples.md → docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# ImplicitEquations

[ImplicitEquations](https://github.com/jverzani/ImplicitEquations.jl)

This paper by [Tupper](https://doi.org/10.1145/383259.383267) details
a method for graphing two-dimensional implicit equations and
inequalities. This package gives an implementation of the paper's
basic algorithms to allow the `Julia` user to naturally represent and
easily render graphs of implicit functions and equations.

This paper by
[Tupper](https://doi.org/10.1145/383259.383267)
details a method for graphing two-dimensional implicit equations and
inequalities. This package gives an
implementation of the paper's basic algorithms to allow
the `julia` user to naturally represent and easily render graphs of
implicit functions and equations.

The [IntervalConstraintProgramming](https://github.com/JuliaIntervals/IntervalConstraintProgramming.jl) packages gives an alternative implementation.

The basic idea is to express a equation in $x$ and $y$ variables in terms of a function of two variables as a predicate. The `plot` function `Plots` is used to plot these predicates.

## Examples


The basic idea is to express a equation in ``x`` and ``y`` variables in terms of a function of two variables as a predicate. The `plot` function `Plots` is used to plot these predicates.

```@example IE
using Plots, ImplicitEquations
```


For example, the
[Devils curve](http://www-groups.dcs.st-and.ac.uk/~history/Curves/Devils.html)
is graphed over the default region as follows:

```
using Plots, ImplicitEquations
```@example IE
a,b = -1,2
f(x,y) = y^4 - x^4 + a*y^2 + b*x^2
r = (f ⩵ 0) # \Equal[tab]
Expand All @@ -42,7 +46,7 @@ For example, the
[Trident of Newton](http://www-history.mcs.st-and.ac.uk/Curves/Trident.html)
can be represented in Cartesian form as follows:

```
```@example IE
## trident of Newton
c,d,e,h = 1,1,1,1
f(x,y) = x*y
Expand All @@ -53,14 +57,14 @@ plot(Eq(f,g)) ## aka f ⩵ g (using Unicode\Equal<tab>)

Inequalities can be graphed as well

```
```@example IE
f(x,y) = x - y
plot(f ≪ 0) # \ll[tab]
```

This example is from Tupper's paper:

```
```@example IE
f(x,y) = (y-5)* cos(4sqrt((x-4)^2 +y^2))
g(x,y) = x * sin(2*sqrt(x^2 + y^2))
Expand All @@ -81,13 +85,7 @@ predicate.

* If definitely not, the region is labeled "white;"
* if definitely yes, the region is labeled "black;"
* else the square region is subdivided into 4 smaller regions and the
above is repeated until subdivision would be below the pixel level. At
which point, the remaining "1-by-1" pixels are checked for possible
solutions, for example for equalities where continuity is known a
random sample of points is investigated with the intermediate value
theorem. A region may be labeled "black" or "red" if the predicate is
still ambiguous.
* else the square region is subdivided into 4 smaller regions and the above is repeated until subdivision would be below the pixel level. At which point, the remaining "1-by-1" pixels are checked for possible solutions, for example for equalities where continuity is known a random sample of points is investigated with the intermediate value theorem. A region may be labeled "black" or "red" if the predicate is still ambiguous.


The graph plots each "black" region as a "pixel". The "red" regions
Expand All @@ -96,7 +94,7 @@ keyword `red`.

For example, the Devil's curve is a bit different with red coloring:

```
```@example IE
a,b = -1,2
f(x,y) = y^4 - x^4 + a*y^2 + b*x^2
r = (f ⩵ 0)
Expand All @@ -119,7 +117,7 @@ This example, the
Uses a few new things: the `screen` function is used to restrict
ranges and logical operators to combine predicates.

```
```@example IE
f0(x,y) = ((x/7)^2 + (y/3)^2 - 1) * screen(abs(x)>3) * screen(y > -3*sqrt(33)/7)
f1(x,y) = ( abs(x/2)-(3 * sqrt(33)-7) * x^2/112 -3 +sqrt(1-(abs((abs(x)-2))-1)^2)-y)
f2(x,y) = y - (9 - 8*abs(x)) * screen((abs(x)>= 3/4) & (abs(x) <= 1) )
Expand Down Expand Up @@ -153,50 +151,48 @@ The above example illustrates a few things:
by slow, it can mean really slow. The difference between rendering
`(1-x^2)*(2-y^2)` and `csc(1-x^2)*cot(2-y^2)` can be 10 times.)

## Maps
### Maps

If a function $f:C \rightarrow C$ is passed through the `map` argument
of `plot`, each rectangle to render is mapped by the function $f$
If a function ``f:C \rightarrow C`` is passed through the `map` argument
of `plot`, each rectangle to render is mapped by the function ``f``
prior to drawing. This allows for viewing of conformal maps. This
example is one of
[several](http://mathfaculty.fullerton.edu/mathews/c2003/ConformalMapDictionary.1.html):

```
```@example IE
f(x,y) = x
plot(f ≧ 1/2, map=z -> 1/z)
```

The region that is mapped above is not the half plane $x >= 1/2$, but
truncated by $|y| < 5$ due to the default values of `ylims`. Hence we
The region that is mapped above is not the half plane ``x >= 1/2``, but
truncated by ``|y| < 5`` due to the default values of `ylims`. Hence we
don't see the full circle.

As well, the pieces plotted are polygonal approximations to the
correct image. Consequently, gaps can appear.

## A "typical" application
### A "typical" application

A common calculus problem is to find the tangent line using implicit
differentiation. We can plot the predicate to create the implicit graph, then add a layer with `plot!`:

```
```@example IE
f(x,y) = x^2 + y^2
plot(f ⩵ 2*3^2)
## now add tangent at (3,3)
a,b = 3,3
dydx(a,b) = -b/a # implicit differentiate to get dy/dx =-y/x
dydx(a,b) = -b/a # implicit differentiation to get dy/dx = -y/x
tl(x) = b + dydx(a,b)*(x-a)
plot!(tl, linewidth=3, -5, 5)
```

## 3D Plots
### 3D Plots

Embedding in 3D is done using the `zpos` keyword. This can be used to create Z-scans.
The following example produces cross sections through an ellipsoid:
Embedding in 3D is done using the `zpos` keyword. This can be used to create Z-scans. The following example produces cross sections through an ellipsoid, though it isn't displayed.

```
using Plots, ColorSchemes
gr()
using ImplicitEquations
Expand All @@ -208,7 +204,7 @@ plt = plot( palette = palette(cgrad([:red,:green,:blue],length(zrange))), camera
plt
```

## Alternatives
### Alternatives

Many such plots are simply a single level of a contour plot. Contour
plots can be drawn with the `Plots` package too. A simple contour plot
Expand All @@ -223,18 +219,9 @@ The package
[IntervalConstraintProgramming ](https://github.com/dpsanders/IntervalConstraintProgramming.jl)
also allows for this type of graphing, and more.

## TODO

*LOTS*:
## Reference

* Check out these graphs to see which can be done
- http://www.xamuel.com/graphs-of-implicit-equations/
- http://www.peda.com/grafeq/gallery.html

* branch cut tracking and interval sets are employed by Tupper, these
could be added. This would allow some other functions such as `mod`,
or `±` to be defined.

* Tupper sketches out how to be more rigorous with computing whether a region is black or white.

* increase speed (could color 1-pixel regions better if so, perhaps; division checks; type stability).
```@autodocs
Modules = [ImplicitEquations]
```
Loading

2 comments on commit ae434a5

@jverzani
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/59241

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.8 -m "<description of version>" ae434a55b10d2700bd8596ed89167d7fd017a75a
git push origin v1.0.8

Please sign in to comment.