Skip to content

Commit

Permalink
Fix Rotate and Scale of RegularGrid (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Sep 18, 2024
1 parent e5d3d51 commit a9b2511
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transforms/rotate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ applycoord(t::Rotate, b::Box) = TransformedGeometry(b, t)

applycoord(t::Rotate, e::Ellipsoid) = Ellipsoid(radii(e), applycoord(t, center(e)), t.rot * rotation(e))

applycoord(t::Rotate, g::CartesianGrid) = TransformedGrid(g, t)
applycoord(t::Rotate, g::RegularGrid) = TransformedGrid(g, t)

applycoord(t::Rotate, g::RectilinearGrid) = TransformedGrid(g, t)

Expand Down
2 changes: 2 additions & 0 deletions src/transforms/scale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function applycoord(t::Scale, g::CartesianGrid)
CartesianGrid(dims, orig, spac, offs)
end

applycoord(t::Scale, g::RegularGrid) = TransformedGrid(g, t)

applycoord(t::Scale, g::RectilinearGrid) =
RectilinearGrid{manifold(g),crs(g)}(ntuple(i -> t.factors[i] * xyz(g)[i], paramdim(g)))

Expand Down
20 changes: 20 additions & 0 deletions test/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@
@test r SimpleMesh(f.(vertices(d)), topology(d))
@test TB.revert(f, r, c) d

# ------------
# REGULARGRID
# ------------

f = Rotate(Angle2d(T/ 2)))
d = RegularGrid(merc(0, 0), merc(1, 1), dims=(10, 10))
r, c = TB.apply(f, d)
@test r SimpleMesh(f.(vertices(d)), topology(d))
@test TB.revert(f, r, c) d

# ----------------
# RECTILINEARGRID
# ----------------
Expand Down Expand Up @@ -851,6 +861,16 @@ end
@test r CartesianGrid(cart(1, 2), cart(11, 22), dims=(10, 10))
@test TB.revert(f, r, c) d

# ------------
# REGULARGRID
# ------------

f = Scale(T(1), T(2))
d = RegularGrid(merc(1, 1), merc(11, 11), dims=(10, 10))
r, c = TB.apply(f, d)
@test r RegularGrid(merc(1, 2), merc(11, 22), dims=(10, 10))
@test TB.revert(f, r, c) d

# ----------------
# RECTILINEARGRID
# ----------------
Expand Down

0 comments on commit a9b2511

Please sign in to comment.