当前位置: 首页>>代码示例>>C#>>正文


C# ILArray.GetLimits方法代码示例

本文整理汇总了C#中ILArray.GetLimits方法的典型用法代码示例。如果您正苦于以下问题:C# ILArray.GetLimits方法的具体用法?C# ILArray.GetLimits怎么用?C# ILArray.GetLimits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILArray的用法示例。


在下文中一共展示了ILArray.GetLimits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Map

        /// <summary>
        /// map all elements in A into final colors
        /// </summary>
        /// <param name="A">array with elements to map</param>
        /// <returns>colors as ILArray, the i-th row represents the color for the i-th element of A as RGB tripel.</returns>
        public ILArray<float> Map (ILArray<float> A) {
            ILArray<float> ret = new ILArray<float>(A.Dimensions.NumberOfElements,3); 
            float min, max;
            if (!A.GetLimits(out min, out max) || min == max) {
                // special case: all constant: eturn middle of colormap
                return ILMath.repmat(m_map[m_map.Length / 2, null], ret.Dimensions[0], 1);
            }

            float dist = (m_map.Dimensions[0]-1) / (A.MaxValue - min);
            for (int i = 0; i < ret.Dimensions[0]; i++) {
                double index = (double)(A.GetValue(i)-min)*dist;
                if (index >= m_map.Dimensions[0] - 1) {
                    ret[i, null] = m_map["end;:"];
                    continue;
                } else if (index < 0) {
                    ret[i, null] = m_map["0;:"];
                    continue;
                }
                int find = (int)Math.Floor(index); 
                if (find == index) { 
                    ret[i,null] = m_map[find,null];
                    continue; 
                }
                // interpolate
                index = index - find; 
                float r1 = m_map.GetValue(find,0);
                float g1 = m_map.GetValue(find,1); 
                float b1 = m_map.GetValue(find,2); 
                r1 = (float)(index*(m_map.GetValue(find+1,0)-r1)+r1); 
                g1 = (float)(index*(m_map.GetValue(find+1,1)-g1)+g1); 
                b1 = (float)(index*(m_map.GetValue(find+1,2)-b1)+b1); 
                ret.SetValue(r1,i,0); 
                ret.SetValue(g1,i,1); 
                ret.SetValue(b1,i,2); 
            }
            return ret; 
        }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:42,代码来源:ILColormap.cs

示例2: configureVertices

            public static ILArray<int> configureVertices(
                    ILArray<float> xVals, ILArray<float> yVals,
                    ILArray<float> zVals, ILColormap cmap, C4fN3fV3f[] Vertices, byte opacity) {
                int i = 0, x, y, y0 = zVals.Dimensions[0] - 1;
                float minZ, maxZ;
                if (!zVals.GetLimits(out minZ, out maxZ,false))
                    minZ = maxZ = 1.0f;
                x = 0;
                y = 0;
                ILArray<float> colors = (tosingle((zVals - minZ) / (maxZ - minZ)))[":"] * (cmap.Length - 1);
                colors[isnan(colors)] = 0;
                bool useXvals = (xVals != null && !xVals.IsEmpty);
                bool useYvals = (yVals != null && !yVals.IsEmpty);
                foreach (float a in zVals.Values) {
                    C4fN3fV3f v = Vertices[i];
                    v.Position = new ILPoint3Df(
                         (useXvals)? xVals.GetValue(y,x): x 
                        ,(useYvals)? yVals.GetValue(y,x): y0 - y
                        , a);
                    byte r, g, b;
                    cmap.Map(colors.GetValue(i), out r, out g, out b);
                    v.Color = Color.FromArgb(255, r, g, b);
                    v.Alpha = opacity; 
                    Vertices[i++] = v;
                    // set next position
                    if (++y >= zVals.Dimensions[0]) {
                        x++;
                        y = 0;
                    }
                }

                // create quad indices
                int numQuad = (zVals.Dimensions[0] - 1) * (zVals.Dimensions[1] - 1);
                x = 0; y = 0;
                ILArray<double> ret = zeros(4, numQuad);
                ILArray<double> mult = counter(0.0, 1.0, zVals.Dimensions.ToIntArray());
                mult = mult["0:" + (zVals.Dimensions[0] - 2), "0:" + (zVals.Dimensions[1] - 2)];
                mult = mult[":"].T; 

                ret["0;:"] = mult;
                ret["3;:"] = mult + 1;
                mult = mult + zVals.Dimensions.SequentialIndexDistance(1); 
                ret["2;:"] = mult + 1;
                ret["1;:"] = mult; 
                return toint32(ret); 
            }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:46,代码来源:ILLitSurface.cs


注:本文中的ILArray.GetLimits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。