algorithmic modeling for Rhino
here is my code:
private Point3d[,] UVPointMatrix(Surface srf, int u, int v,bool swap)
{
Interval domU = srf.Domain(0);
Interval domV = srf.Domain(1);
/*if (swap)
{
int temp = u;
u = v;
v = temp;
}*/
Point3d[,] ptArr = new Point3d[u+1, v+1];
double numU = domU.Length / u;
double numV = domV.Length / v;
int uC = 0;
for (double i = domU.Min; i <= domU.Max; i+=numU)
{
int vC = 0;
for (double j = domV.Min; j <= domV.Max;j+=numV)
{
Point3d p = srf.PointAt(i, j);
/*if (swap)
{
ptArr[vC, uC] = p;
}
else
{*/
ptArr[uC, vC] = p;
//}
vC++;
}
uC++;
}
return ptArr;
}
It goes wrong sometimes. "Out of Index"pops up ,or, one row of points are missing.
I use Microsoft.VisualBasic.CompilerServices.ObjectFlowControl.ForLoopControl.ForNextCheckR8
to control the loop, the problem is solved.... but ,MSDN says "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code."
Code C# in VS refering to some VB Compile Method......
anyone has the same problem?
Tags:
for (int i = 0; i <= u; i++)
{
double ti = (double)i / (double)u;
ti = domU.ParameterAt(ti);
...
}
for (double i = domU.Min; i <= (domU.Max + 0.5 * numU); i+=numU)
{
...
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2025 Created by Scott Davidson.
Powered by