Skip to content

Commit deb109c

Browse files
committed
recenter to center-of-mass origin before rotation
1 parent aabbbbb commit deb109c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/NetworkLayout.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ macro addcall(expr::Expr)
214214
@assert typedef isa Expr &&
215215
typedef.head === :<: &&
216216
typedef.args[2] isa Expr && # supertype
217-
typedef.args[2].args[1] [:AbstractLayout, :IterativeLayout] "Macro musst be used on subtype of AbstractLayout"
217+
typedef.args[2].args[1] [:AbstractLayout, :IterativeLayout] "Macro must be used on subtype of AbstractLayout"
218218

219219
if typedef.args[1] isa Symbol # no type parameters
220220
name = typedef.args[1]

src/align.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export Align
55
66
Align the vertex positions of `inner_layout` so that the principal axis of the resulting
77
layout makes an `angle` with the **x**-axis.
8+
Also automatically centers the layout origin to its center of mass (average node position).
89
910
Only supports two-dimensional inner layouts.
1011
"""
@@ -40,7 +41,7 @@ function layout(algo::Align{Ptype, <:AbstractLayout{2, Ptype}}, adj_matrix::Abst
4041
s, c = sincos(-axis_angle + algo.angle)
4142
R = @SMatrix [c -s; s c] # [cos(θ) -sin(θ); sin(θ) cos(θ)]
4243
for (i, r) in enumerate(rs)
43-
rs[i] = Point2{Ptype}(R * r) :: Point2{Ptype}
44+
rs[i] = Point2{Ptype}(R * (r-centerofmass)) :: Point2{Ptype}
4445
end
4546

4647
return rs

0 commit comments

Comments
 (0)