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

Shear transformation #333

Merged
merged 1 commit into from Dec 9, 2018
Merged

Shear transformation #333

merged 1 commit into from Dec 9, 2018

Conversation

Mattriks
Copy link
Member

@Mattriks Mattriks commented Dec 4, 2018

This PR:

  • Closes Affine transformations #115 (Rotation, Reflection and Shearing are the 3 main transformations)
  • Adds example test to examples/transformations.jl
  • Adds gallery example + documentation
set_default_graphic_size(15cm, 5cm)

f_points = [(.1, .1), (.9, .1), (.9, .2), (.2, .2), (.2, .4), (.6, .4),
    (.6, .5), (.2, .5), (.2, .9), (.1, .9), (.1, .1)]
f_points = (x->0.5.*x.+0.3).(f_points)

ctxl(θ, x, y) = (context(rotation=Rotation(θ, x, y)), circle(x,y, 0.01), 
    line([(x-0.5,y),(x+0.5,y)]))
fpoly(c::String) = (context(),  polygon(f_points), fill(c) )
ctxf(θ, ϕ, s, x, y,c) = (context(rotation=Rotation(-θ, x, y), 
        shear=Shear(s, ϕ, x, y)), fpoly(c))

x, y, θ  = 0.5, 0.5, -π/6

img1 = compose(context(), stroke("black"), ctxl(θ,x,y),  ctxf(0,0,0,x,y, "yellow"),
#    (context(), arc(x,y,0.3,π+θ,π-0.15), arrow())
)
img2 = compose(context(), stroke("black"), ctxl(0,x,y),
    ctxf(θ,0,1.8,x,y,"transparent"), ctxf(θ,0,0,x,y,"yellow"),
    text(0.5, 0.1, "x' = x+y*shear", hcenter, vcenter) )
img3 = compose(context(), stroke("black"), 
    ctxl(θ, x, y), ctxf(0,θ,1.8,x,y,"yellow") )

hstack(img1, img2, img3)

fshear

@codecov-io
Copy link

codecov-io commented Dec 4, 2018

Codecov Report

Merging #333 into master will increase coverage by 0.26%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #333      +/-   ##
=========================================
+ Coverage   32.54%   32.8%   +0.26%     
=========================================
  Files          18      18              
  Lines        3073    3088      +15     
=========================================
+ Hits         1000    1013      +13     
- Misses       2073    2075       +2
Impacted Files Coverage Δ
src/Compose.jl 12.04% <ø> (ø) ⬆️
src/container.jl 44.85% <100%> (+0.68%) ⬆️
src/measure.jl 40.33% <83.33%> (+4.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84afc6c...79548b2. Read the comment docs.

@bjarthur bjarthur merged commit de6d521 into GiovineItalia:master Dec 9, 2018
@gregconner
Copy link

It would be easy to add an option to multiply a context by a 2x2 matrix instead of making users who are interested in this feature decompose their matrix into a product of elementary matrices and then rewrite those as reflections, shears and scalings. I can write the code if you would like.

@Mattriks
Copy link
Member Author

Mattriks commented Jun 5, 2023

@gregconner An interesting suggestion! Yes we're happy to look at PRs

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

Successfully merging this pull request may close these issues.

Affine transformations
4 participants