Hi kangaroo specialists,
I was about to look into scripting a kangaroo node with c#, but I seem to have a lack of understanding how the entire thing works exactly and therefor just code undirectionned gibberish. Usually the transition between grasshopper and c# is pretty easy, but in this case I really need to understand how Kangaroo works in some steps to stop shooting in the dark with my miserable tries to obtain a pretty simple definition. I sadly already fail doing a simple onMesh goal and feed it into a solver:
private void RunScript(Mesh M, int iter, Mesh onmesh, ref object A)
{
var PS = new KangarooSolver.PhysicalSystem();
List<IGoal> goals = new List<IGoal>();
Point3d[] pts = M.Vertices.ToPoint3dArray();
for(int i = 0;i < pts.Length;i++) PS.AddParticle(pts[i], 1);
//settings
//bool byCurr = false;
double thresh = 0.05;
//weights
//int tick = 1;
int omk = 1;
//TangentInCircles
/*for(int i = 0;i < M.Faces.Count;i++)
{
TangentIncircles tiC = new TangentIncircles(M.Faces[i].A, M.Faces[i].B, M.Faces[i].C, 1, tick);
PS.AssignPIndex(tiC, 0.01, byCurr);
goals.Add(tiC);
}
*/
//onMeshGoal
OnMesh om = new OnMesh(new List<Point3d>(pts), M, omk);
PS.AssignPIndex(om, 0.001);
goals.Add(om);
int cnt = 0;
for(int i = 0;i < iter;i++)
{
PS.Step(goals, true, thresh);
cnt++;
}
M.Vertices.Clear();
M.Vertices.AddVertices(PS.GetPositions());
M.Vertices.CombineIdentical(true, true);
M.Compact();
A = M;
}
although it is an embarrassing piece of code, it’s the best I could come up with. As you can see, it’s intended to be a circle packing code.
Is there any chance I can find an example for TangentIncircles and OnMesh goals fed into a solver in c#? or some general information on how kangaroo works (e.g. it still makes no sens to me how you can assign all the correct points to the particles)?
If someone could point in the right direction, that would save me a ton of time
thank you
Ben