コード例 #1
0
            public static Table3d Load(string filename)
            {
                using (BinaryReader bw = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read)))
                {
                    int size = bw.ReadUInt16();

                    Table3d table = new Table3d(size);

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            for (int k = 0; k < size; k++)
                            {
                                Vector4d value = new Vector4d();
                                value.X = bw.ReadDouble();
                                value.Y = bw.ReadDouble();
                                value.Z = bw.ReadDouble();
                                value.W = bw.ReadDouble();
                                table.Table[i, j, k] = value;
                            }
                        }
                    }
                    return(table);
                }
            }
コード例 #2
0
        /// <summary>
        /// Uniformly sample the LRTF into a 3D table.
        /// </summary>
        /// <param name="sampleCount">Number of samples in each dimension</param>
        /// <returns>3D table of LRTF: [position phi, direction theta, direction phi]
        /// </returns>
        public Table3d SampleLrtf3D(int sampleCount)
        {
            Table3d table = new Table3d(sampleCount);

            // position phi is always 0.0 as it is separable
            Parameters inputParams = new Parameters(0, 0, 0, 0);
            double     step        = 1 / (double)(sampleCount - 1);

            for (int i = 0; i < sampleCount; i++)
            {
                inputParams.DirectionTheta = 0.0;
                for (int j = 0; j < sampleCount; j++)
                {
                    inputParams.DirectionPhi = 0.0;
                    for (int k = 0; k < sampleCount; k++)
                    {
                        table.Table[i, j, k]      = ComputeLrtf(inputParams).ToVector4d();
                        inputParams.DirectionPhi += step;
                    }
                    inputParams.DirectionTheta += step;
                }
                inputParams.PositionTheta += step;
            }
            return(table);
        }
コード例 #3
0
        public Table3d SampleLrtf3DCached(int sampleCount, string filename)
        {
            Table3d table;

            if (File.Exists(filename))
            {
                table = Table3d.Load(filename);
            }
            else
            {
                table = SampleLrtf3D(sampleCount);
                table.Save(filename);
            }
            return(table);
        }
コード例 #4
0
            public static Table3d Load(string filename)
            {
                using (BinaryReader bw = new BinaryReader(File.Open(filename, FileMode.Open, FileAccess.Read)))
                {
                    int size = bw.ReadUInt16();

                    Table3d table = new Table3d(size);

                    for (int i = 0; i < size; i++)
                    {
                        for (int j = 0; j < size; j++)
                        {
                            for (int k = 0; k < size; k++)
                            {
                                Vector4d value = new Vector4d();
                                value.X = bw.ReadDouble();
                                value.Y = bw.ReadDouble();
                                value.Z = bw.ReadDouble();
                                value.W = bw.ReadDouble();
                                table.Table[i, j, k] = value;
                            }
                        }
                    }
                    return table;
                }
            }
コード例 #5
0
        /// <summary>
        /// Uniformly sample the LRTF into a 3D table.
        /// </summary>
        /// <param name="sampleCount">Number of samples in each dimension</param>
        /// <returns>3D table of LRTF: [position phi, direction theta, direction phi]
        /// </returns>
        public Table3d SampleLrtf3D(int sampleCount)
        {
            Table3d table = new Table3d(sampleCount);

            // position phi is always 0.0 as it is separable
            Parameters inputParams = new Parameters(0, 0, 0, 0);
            double step = 1 / (double)(sampleCount - 1);
            for (int i = 0; i < sampleCount; i++)
            {
                inputParams.DirectionTheta = 0.0;
                for (int j = 0; j < sampleCount; j++)
                {
                    inputParams.DirectionPhi = 0.0;
                    for (int k = 0; k < sampleCount; k++)
                    {
                        table.Table[i, j, k] = ComputeLrtf(inputParams).ToVector4d();
                        inputParams.DirectionPhi += step;
                    }
                    inputParams.DirectionTheta += step;
                }
                inputParams.PositionTheta += step;
            }
            return table;
        }