HaxeFoundation / HaxeFoundation/haxe
Unable to create a `Map<Float, Int>`
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
### Use Case
I'm implementing the hough transform in haxe, and one of the things needed to create the transform is an accumulator, this accumulator should be a 2D array, with `theta:Int` as its first access key, and `rho:Float` as the second. there are 360 thetas:
```haxe
var accum:Array>= [for (i in 0...361) []];
```
and im working with that map like this:
```haxe
var rho:Float;
var theta = 0.;
var thetaIndex = 0;
var x = i - Std.int(image.width / 2);
var y = j - Std.int(image.height / 2);
while (thetaIndex < 360) {
rho = rhoMax + x * Math.cos(theta) + y * Math.sin(theta);
rho /= 2;
if (accum[thetaIndex][rho] == null) {
accum[thetaIndex][rho] = 1;
} else {
accum[thetaIndex][rho]++;
}
houghSpace.setPixel(thetaIndex, Std.int(rho), houghSpace.getPixel(thetaIndex, Std.int(rho)).darken(0.02));
theta += Math.PI / 360;
thetaIndex++;
}
```
### Bug
Running the code below results in a from/to error:
```haxe
class Main {
static function main() {
new Map();
}
}1
```
```text
Main.hx:4: characters 57-59 : Abstract haxe.ds.Map has no @:to function that accepts haxe.IMap
```
just initializing a map with doesnt work.
### TryHaxe
https://try.haxe.org/#AC09f0D8
Contributor guide
Assessment
This issue has not been assessed yet.