Permalink
Browse files

center first histogram bin around 0 degrees

  • Loading branch information...
1 parent c143bda commit d1f5ba8a4bd636418ccfa4237fc94b5b134cd2c0 @harthur committed Jun 5, 2012
Showing with 140 additions and 135 deletions.
  1. +6 −1 hog.js
  2. +134 −134 test/expected.json
View
7 hog.js
@@ -76,7 +76,12 @@ function binFor(radians, bins) {
if (angle < 0) {
angle += 180;
}
- var bin = Math.floor(angle / 181 * bins);
+
+ // center the first bin around 0
+ angle += 90 / bins;
+ angle %= 180;
+
+ var bin = Math.floor(angle / 180 * bins);
return bin;
}
View
268 test/expected.json
@@ -1,144 +1,144 @@
-[ 0.16387327242346084,
- 0.09145168737162668,
+[ 0.16462046530469723,
+ 0.04289648075251454,
+ 0.09145168737162666,
0,
- 0.043643673633750976,
- 0.08953363338052521,
- 0.07634251759352209,
- 0.10457882690738723,
- 0.030073588214373535,
- 0.024908267623772653,
- 0.07580990423047426,
- 0.08232903895078902,
- 0.09365738484182966,
- 0.049907508780986494,
- 0.04221074416027796,
- 0.015818408091016933,
- 0.0158612404722822,
- 0.12395517226750605,
- 0.10569268287618142,
- 0.1447845464926539,
- 0.041635491234577264,
- 0.03371023800226287,
- 0.07668707284996816,
- 0.04825678095888972,
- 0.07455294279801411,
- 0.06909463644904257,
- 0.05843882199764456,
- 0.021899854008898188,
- 0.021959153458701582,
- 0.03826335651790256,
- 0.05871020156677378,
- 0.04588893462477791,
- 0.03646969395826849,
- 0.025625719861198507,
- 0.058295685889156006,
- 0.03668365527922751,
- 0.056673371064352086,
- 0.037579340526655444,
- 0.09973066287083313,
- 0.12465895255395179,
- 0.1350804588222306,
- 0.029086892089314684,
- 0.04463009659687513,
- 0.03488367490447484,
- 0.02772339254132521,
- 0.0748398341718241,
- 0.03626209631116725,
- 0.032768365419077336,
- 0.14547748187152085,
- 0.03079578522905693,
- 0.09372894029325723,
- 0.10178898990242768,
- 0.11579499434763435,
- 0.06170404722445104,
- 0.052188013680965165,
- 0.019557373703966596,
- 0.019610330289876868,
- 0.19269092004646354,
+ 0.07605028943538225,
+ 0.043556932159516455,
+ 0.08461742655538537,
+ 0.09630391794552391,
+ 0.04029357076718436,
+ 0.04406193791026964,
+ 0.04847962581310698,
+ 0.14386946115630458,
+ 0.015861240472282198,
+ 0.09119252126063075,
+ 0.01674413977165062,
0,
+ 0.10528810651402616,
+ 0.06030255698805717,
+ 0.11714891141441479,
+ 0.13332831795442057,
+ 0.0398619474808937,
+ 0.07413691178831866,
+ 0.08198450812183956,
+ 0.03722366721808298,
+ 0.021959153458701586,
+ 0.12625182577286567,
+ 0.023181486682719698,
0,
- 0.18867141681600577,
- 0.04676731728618702,
- 0.020965850474917044,
- 0.01648157276426277,
- 0.03925407292053198,
- 0.1056868958687651,
- 0.08938780218799375,
- 0.03349793427000009,
+ 0.027052954511122742,
+ 0.06148234973747136,
+ 0.02547372679329537,
+ 0.0653231556258333,
+ 0.030302102856663897,
+ 0.05635711420175409,
+ 0.06232266998374163,
+ 0.028296545051774518,
+ 0.06384536312289062,
+ 0.07346464027459795,
+ 0.06384536312289062,
+ 0.19589404825329182,
+ 0.020565011545550103,
+ 0.04673741759624812,
+ 0.019364520255890045,
+ 0.04965710673430159,
+ 0.10771468142738463,
+ 0.06827206068478246,
+ 0.014324686453174917,
+ 0.0990363492082475,
+ 0.04981768183162275,
+ 0.054476770410385664,
+ 0.05993865840354896,
+ 0.1778755991268188,
+ 0.019610330289876864,
+ 0.112747515871328,
+ 0.0207019187380548,
+ 0,
+ 0.22722451815021538,
+ 0.008644292381424766,
+ 0,
+ 0.14549352633082913,
+ 0.033712717651983456,
+ 0.035106871581675546,
+ 0.0275910865378206,
+ 0.027058137674419183,
0.03358863848524071,
- 0.05852748612230434,
- 0.08980290335557312,
- 0.0701915416950526,
- 0.05578390662169354,
- 0.08010321550071904,
- 0.03591037793489518,
- 0.028229692262388084,
- 0.06723450573811342,
- 0.06016337611962815,
- 0.13331867029789599,
- 0.04911067142723518,
- 0.00946173977701384,
- 0.041086566191868956,
- 0.06304205386902231,
- 0.049274787198899814,
- 0.039160560681928865,
- 0.10571469069460131,
- 0.05122187051713312,
- 0.04628681574697559,
- 0.20549360069089062,
- 0.042234968542812355,
- 0.09359032370465996,
- 0.03447591868384149,
- 0.006642185123518727,
- 0.03759021216472055,
- 0.06528153464581027,
- 0.050219333178461605,
- 0.0686841274423686,
- 0.1558092335223495,
+ 0.19311431754241784,
+ 0.035458314784341124,
0,
+ 0.041380097404059596,
+ 0.09404317076425071,
+ 0.03896451663043209,
+ 0.09991805299588118,
+ 0.0577432541333589,
+ 0.06013116558844431,
+ 0.047258104143827105,
+ 0.046345267570485404,
+ 0.024762096308797634,
+ 0.14793811194230275,
+ 0.0756169395683505,
+ 0.0037373098023222666,
+ 0.02904901993338751,
+ 0.06601874121885645,
+ 0.0273532710481534,
+ 0.07014293574132259,
+ 0.1521519169085826,
+ 0.0964374100803665,
+ 0.020234275161778094,
+ 0.1398933754988734,
+ 0.017383106236868243,
+ 0.10385323941499622,
+ 0.05308344162107446,
+ 0.0026236087818936175,
+ 0.07726616766418828,
+ 0.07459169550441612,
+ 0.032580090781012504,
+ 0.0373372534817441,
+ 0.18373298545636382,
+ 0.0069897459100206165,
0,
- 0.15255907665285498,
- 0.03781589635100743,
- 0.016952916576729815,
- 0.013326944616920175,
- 0.031740712083909904,
+ 0.11764557880882001,
+ 0.027259990746031672,
+ 0.028387298951032286,
+ 0.02231006030003925,
+ 0.02187911963146411,
0.09097197439554873,
+ 0,
0.09097197439554873,
- 0.042884599995347654,
- 0.026967550719413286,
+ 0.06985215071476093,
+ 0,
0.011911163257928063,
- 0.16260473404596687,
- 0.1084820808576888,
- 0.057000839288871286,
- 0.05418205328906309,
- 0.02428988647629783,
- 0.019094647835714327,
- 0.04547761971844413,
- 0.04069468660636198,
- 0.09017714524135166,
- 0.03321860426824238,
- 0.006399948935892717,
+ 0.19000581576935707,
+ 0.13808183842316984,
+ 0.03905770889446355,
+ 0.04067289930723594,
+ 0.03196552224595714,
+ 0.031348076871862744,
+ 0.016749155615858425,
+ 0.10006577906562661,
+ 0.05114752290076861,
+ 0.0025279274695950904,
+ 0,
0.017066137382688158,
- 0.2329776420835202,
- 0.15543151037283714,
- 0.08166995390520919,
- 0.09382445307185525,
- 0.021556869426692146,
- 0.06989192823058085,
- 0.014046478677613708,
- 0.03944440312552991,
- 0.08740658710597508,
- 0.032198012253991846,
- 0.006203320061216374,
- 0.035106536913752935,
- 0.06096822746801372,
- 0.046901221687393635,
- 0.0641460028179213,
- 0.09094183684953239,
- 0.020894566802190956,
- 0.06774460309805275,
- 0.013614921594391576,
- 0.12499648554943034,
- 0.2130366095480469,
- 0.03836267970117415,
- 0.05803356429442758 ]
+ 0.27223750402978214,
+ 0.19784160233178438,
+ 0.02914895773024074,
+ 0.08778487115855423,
+ 0.027894101275402348,
+ 0.054491799242544645,
+ 0.016234562819335465,
+ 0.09699140742166894,
+ 0.049576091632925576,
+ 0.002450260672783287,
+ 0.07216100711005964,
+ 0.06966324372446306,
+ 0.030427446236403553,
+ 0.03487029181615539,
+ 0.02825339952908987,
+ 0.08508781207223723,
+ 0.027037096665079592,
+ 0.05281762007776102,
+ 0.11523813123877136,
+ 0.11019140983309342,
+ 0.1856737691026567,
+ 0.02332602891855759 ]

0 comments on commit d1f5ba8

Please sign in to comment.