private static Vector4[] CalculateHemispherePointsAndWeights()
    {
        Binner binner = new Binner(RasterDim, Binner.Mode.Midpoints);

        Vector4[] pointsAndWeights = new Vector4[RasterDim * RasterDim];
        for (int row = 0; row < RasterDim; ++row)
        {
            for (int col = 0; col < RasterDim; ++col)
            {
                int idx = row * RasterDim + col;

                float x        = binner.IdxToFloat(col) * 2 - 1;
                float y        = -(binner.IdxToFloat(row) * 2 - 1);
                float zSquared = 1 - x * x - y * y;
                if (zSquared < 0)
                {
                    pointsAndWeights[idx] = Vector4.Zero;
                }
                else
                {
                    float z = (float)-Math.Sqrt(zSquared);
                    pointsAndWeights[idx] = new Vector4(x, y, z, 1);
                }
            }
        }
        return(pointsAndWeights);
    }
示例#2
0
    public void TestMidpointsIdxToFloat()
    {
        Binner indexer = new Binner(4, Binner.Mode.Midpoints);

        Assert.AreEqual(1 / 8f, indexer.IdxToFloat(0), Acc);
        Assert.AreEqual(3 / 8f, indexer.IdxToFloat(1), Acc);
        Assert.AreEqual(5 / 8f, indexer.IdxToFloat(2), Acc);
        Assert.AreEqual(7 / 8f, indexer.IdxToFloat(3), Acc);
    }
示例#3
0
    public void TestEndpointsIdxToFloat()
    {
        Binner binner = new Binner(5, Binner.Mode.Endpoints);

        Assert.AreEqual(0, binner.IdxToFloat(0), Acc);
        Assert.AreEqual(0.25f, binner.IdxToFloat(1), Acc);
        Assert.AreEqual(0.5f, binner.IdxToFloat(2), Acc);
        Assert.AreEqual(0.75f, binner.IdxToFloat(3), Acc);
        Assert.AreEqual(1, binner.IdxToFloat(4), Acc);
    }