本文整理汇总了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;
}
示例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);
}