Skip to content

Commit d037c2b

Browse files
committed
Merge pull request jacomyal#624 from victor-homyakov/patch-1
Calculate coefficients only once
2 parents f22da0c + ac9d4fc commit d037c2b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/classes/sigma.classes.camera.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@
9898
l,
9999
node,
100100
cos = Math.cos(this.angle),
101-
sin = Math.sin(this.angle);
101+
sin = Math.sin(this.angle),
102+
nodeRatio = Math.pow(this.ratio, this.settings('nodesPowRatio')),
103+
edgeRatio = Math.pow(this.ratio, this.settings('edgesPowRatio'));
102104

103105
for (i = 0, l = nodes.length; i < l; i++) {
104106
node = nodes[i];
@@ -114,13 +116,13 @@
114116
) / this.ratio + (options.height || 0) / 2;
115117
node[write + 'size'] =
116118
(node[read + 'size'] || 0) /
117-
Math.pow(this.ratio, this.settings('nodesPowRatio'));
119+
nodeRatio;
118120
}
119121

120122
for (i = 0, l = edges.length; i < l; i++) {
121123
edges[i][write + 'size'] =
122124
(edges[i][read + 'size'] || 0) /
123-
Math.pow(this.ratio, this.settings('edgesPowRatio'));
125+
edgeRatio;
124126
}
125127

126128
return this;

0 commit comments

Comments
 (0)