Skip to content

Commit f1e110f

Browse files
committed
Merge pull request #26 from jdunkerley/ImproveMessaging
Bug fix for Hex Bins
2 parents e9f52ea + 1e70b32 commit f1e110f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

AlteryxAddIns/HexBin.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,23 @@ private bool PushFunc(RecordData r)
154154
return true;
155155
}
156156

157-
double dx = 2 * 0.86602540378443864676372317075294 * this.ConfigObject.Radius; // 2 * Sin(π/3)
158-
double dy = 1.5 * this.ConfigObject.Radius;
157+
double dy = 2 * 0.86602540378443864676372317075294 * this.ConfigObject.Radius; // 2 * Sin(π/3)
158+
double dx = 1.5 * this.ConfigObject.Radius;
159159

160-
double px = point.Item1.Value / dy;
160+
double px = point.Item1.Value / dx;
161161
int pi = (int)Math.Round(px);
162162
bool mod2 = (pi & 1) == 1;
163-
double py = point.Item2.Value / dx - (mod2 ? 0.5 : 0);
163+
double py = point.Item2.Value / dy - (mod2 ? 0.5 : 0);
164164
double pj = Math.Round(py);
165-
double py1 = (px - pi) * dy;
165+
double px1 = (px - pi) * dx;
166166

167-
if (Math.Abs(py1) * 3 > 1)
167+
if (Math.Abs(px1) * 3 > 1)
168168
{
169-
double px1 = (py - pj) * dx;
169+
double py1 = (py - pj) * dy;
170170
double pj2 = pj + (py < pj ? -1 : 1) / 2.0;
171171
int pi2 = pi + (px < pi ? -1 : 1);
172-
double px2 = px - pi2;
173-
double py2 = py - pj2;
172+
double px2 = (px - pi2) * dx;
173+
double py2 = (py - pj2) * dy;
174174

175175
if (px1 * px1 + py1 * py1 > px2 * px2 + py2 * py2)
176176
{
@@ -180,8 +180,8 @@ private bool PushFunc(RecordData r)
180180
}
181181
}
182182

183-
this._outputBinYFieldBase.SetFromDouble(record, (pj + (mod2 ? 0.5 : 0)) * dx);
184-
this._outputBinXFieldBase.SetFromDouble(record, pi * dy);
183+
this._outputBinYFieldBase.SetFromDouble(record, (pj + (mod2 ? 0.5 : 0)) * dy);
184+
this._outputBinXFieldBase.SetFromDouble(record, pi * dx);
185185

186186
this.Output?.PushRecord(record.GetRecord());
187187
return true;

0 commit comments

Comments
 (0)