feat: add arrow heads
fix: wasted space generated around the field
This commit is contained in:
parent
d3b6a4d0d7
commit
727c218549
@ -60,7 +60,7 @@ estimation size:
|
||||
dy/dx =
|
||||
y/x
|
||||
range - format: (lower, upper):
|
||||
(-10, 10)
|
||||
(-20, 20)
|
||||
estimation size:
|
||||
0.1
|
||||
```
|
||||
|
10
app/Main.hs
10
app/Main.hs
@ -7,6 +7,8 @@ module Main where
|
||||
import Graphics.Rendering.Chart.Backend.Cairo
|
||||
import Control.Lens
|
||||
import Data.Default.Class
|
||||
import Data.Colour.SRGB
|
||||
import Data.Colour
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
@ -22,14 +24,18 @@ module Main where
|
||||
|
||||
let chart = toRenderable layout
|
||||
where
|
||||
color = opaque (sRGB 0.3 0.3 1)
|
||||
|
||||
layout = layout_title .~ "slope field"
|
||||
$ layout_plots .~ [vectors]
|
||||
$ def
|
||||
|
||||
vectors = plotVectorField
|
||||
$ plot_vectors_values .~ field
|
||||
$ plot_vectors_scale .~ 0
|
||||
$ plot_vectors_style . vector_head_style . point_radius .~ 0
|
||||
$ plot_vectors_scale .~ 1
|
||||
$ plot_vectors_grid .~ []
|
||||
$ plot_vectors_style . vector_head_style . point_color .~ color
|
||||
$ plot_vectors_style . vector_line_style . line_color .~ color
|
||||
$ def
|
||||
|
||||
renderableToFile def "slope-field.png" chart
|
||||
|
BIN
minusy.png
BIN
minusy.png
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 31 KiB |
@ -1,5 +1,5 @@
|
||||
name: slope-field
|
||||
version: 0.1.0.0
|
||||
version: 0.1.0.1
|
||||
synopsis: Visualize mathematical function's slope fields
|
||||
description: Visualize mathematical function's slope fields
|
||||
homepage: https://github.com/mdibaiee/slope-field
|
||||
@ -31,6 +31,7 @@ executable slope-field
|
||||
, Chart-cairo
|
||||
, lens
|
||||
, data-default-class
|
||||
, colour
|
||||
default-language: Haskell2010
|
||||
|
||||
source-repository head
|
||||
|
@ -18,4 +18,9 @@ module Lib
|
||||
half = diff / 2
|
||||
res = map (\(x, y) -> ((x - half, y), (half, d x y * diff))) pts
|
||||
inf = 1/0
|
||||
in filter (\((x0, y0), (x, y)) -> x < inf && y < inf && x > -inf && y > -inf) res
|
||||
noinf = filter (\((x0, y0), (x, y)) -> x < inf && y < inf && x > -inf && y > -inf) res
|
||||
(minx, miny) = head pts
|
||||
(maxx, maxy) = last pts
|
||||
limitX = min maxx . max minx
|
||||
limitY = min maxy . max miny
|
||||
in map (\((x0, y0), (x1, y1)) -> ((limitX x0, limitY y0), (limitX x1, limitY y1))) noinf
|
||||
|
BIN
xpy.png
BIN
xpy.png
Binary file not shown.
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 60 KiB |
BIN
xty.png
BIN
xty.png
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 55 KiB |
Loading…
Reference in New Issue
Block a user