I am making GH components in c# dotnet smoothly. Recently started with Kangaroo custom goals. Some work fine.
Here I tried to implement angleclamp from Daniel Piker’s goals available in Github.
I want to run custom goal integrated with KangarooSolver.PhysicalSystem in same component, as I have some calculation at later stage while KangarooSolver.PhysicalSystem is running. I want to implement Rod and AngleClamp.
It shows in debugging KangarooSolver.PhysicalSystem is null hence, in AngleClamp Calculate method PIndex is becoming null.
I have attached the code, one GH definition, gh component and 3dm file.
Please some one help me with this. Angle clamp and Rod need to work to go for next step.
Many thanks for the reply ! Yes, I did few components in c# with PhysicalSystem. It works with custom spring goal.
I have separated angleclamp bit in the code. If you see, it works without AngleClamp.
You create your instances of your custom goal by setting the positions PPos, and the indexing PIndex is not getting assigned.
When the solver runs it uses the PIndex to identify which particles to apply each goal to.
One way you can set your PIndex values is when you first create the goal (as you are doing with the other goals, such as the anchors). For this you need to also include a constructor which takes integer inputs, like this one:
This means that when you then create instances of that goal you need to know the indices of the particles you are applying it to.
It works now with AssignPIndex. But result is quite funny. I am looking into code, I think I did something wrong . At list now it can find the particle index and running. Many thanks ! If I am not able to solve the imperfection, I will write you back.
I have another question regarding custom spring, which is running but it need to be more improved. after solving this, I will ask you again.
Thanks again !
It works, but angles are getting funny and giving trail of points when moving particles. That never happened before. So, I am deleting the point list output. I gave angle 1.5 degree and 0.5, strength 1.
It gives 8 or 9 degree angular deviation, at list. Not sure if the angle is in radian in angleclamp.
Code and compiled component inside bin folder. definition and 3dm file is also included in zip folder.
Are you adding these angleclamp goals after the particles have started moving?
The default behaviour for AssignPIndex is to compare the positions of the points in the PPos of the goal to the initial positions of the particles in the system.
It sounds like what is happening is that new particles keep getting created because the goals are being created at new locations in space, resulting in the trails you are seeing.
If instead you want to do the indexing comparing the points in the goal to the current positions of the particles, you can use this method:
Dear Daniel, It looks working now. I have converted degree to radian. Minimum and maximum value for angle looks much bigger that 1.5 degree. If I increase strength in angle clamp it become even more deviated. But yes, at list it looks quite smooth, even though not following exact min and max angle 1.5 and 0.5 degree.
I gave angleclamp strength to 100.