algorithmic modeling for Rhino
Found with reflector: GH_Field, GH_LineCharge and so on. ;) I Suppose that I must search in GH SDK :)
For now yes. I'll upload new SDK documentation someday soon.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Nice find, it's seems pretty straight forward to use. This code should do something random, no inputs required:
Dim size As New interval(0, 10)
Dim bx As New box(plane.WorldXY, size, size, size)
Dim rnd As New random(666)
Dim field As New gh_field
Dim crvlist As New list(Of curve)
For i As Integer = 1 To 100
Dim pc As New gh_pointcharge
pc.Charge = rnd.NextDouble
pc.Location = bx.PointAt(rnd.NextDouble, rnd.NextDouble, rnd.NextDouble)
field.Elements.Add(pc)
Next
For i As Integer = 1 To 500
Dim p As New point3d(bx.PointAt(rnd.NextDouble * 0.5 + 0.25, rnd.NextDouble * 0.5 + 0.25, rnd.NextDouble * 0.5 + 0.25))
Dim pts As point3dlist = field.SolveSteps(p, 0.1, 30, gh_differentialsolver.RungeKutta4)
Dim crv As nurbscurve = nurbscurve.CreateInterpolatedCurve(pts.ToArray, 3)
crvlist.add(crv)
Next
a = crvlist
I'm playing with it too :) Have you tried to input a merged field into a custom VB component in GH? It always gives me an error talking about that reference value is a List of GH_Fields and I cannot convert it into GH_Field.
:)
Try this:
field.Elements.AddRange(x)
Didn't work :S "La expresión no genera ningún valor" at AddRange line.
Dim field As GH_Field
Dim origin As Point3d
Dim force As Vector3d
Dim pt_list As List(Of Point3d)
Dim iterations As Integer = Ifield = field.Elements.AddRange(F)
origin = P
For i = 0 To iterations - 1
pt_list.Add(origin)
force = field.TensorAt(origin)
origin = force + origin
NextPa = PolylineCurve.CreateControlPointCurve(pt_list)
The file I'm playing with.
This should work:
Dim field As New GH_Field
Dim origin As Point3d = p
Dim force As New Vector3d
Dim pt_list As New List(Of Point3d)
Dim iterations As Integer = I
'Dim part_path As PolylineCurve
field.Elements.AddRange(F)
For i = 0 To iterations - 1
pt_list.Add(origin)
force = field.TensorAt(origin)
origin = force + origin
Next
Pa = PolylineCurve.CreateControlPointCurve(pt_list)
Ok...here it is (thanks Vicente for your help), the code for a component that draws the path of a moving particle.
Dim field As New GH_Field
Dim origin As Point3d = Nothing
Dim force As New Vector3d
Dim pt_list As New List(Of Point3d)
Dim iterations As Integer = I
Dim particle As New GH_PointChargeparticle.Location = P
particle.Charge = 1origin = particle.Location()
If origin = Nothing Then Return
'Dim part_path As PolylineCurve
field.Elements.AddRange(F)
field.Elements.Add(particle)For i = 0 To iterations - 1
pt_list.Add(origin)
force = field.TensorAt(origin)
origin = force + origin
Next
Pa = PolylineCurve.CreateControlPointCurve(pt_list)End Sub
An updated version with some extras.
I'm not sure but I think what you are trying to do is the same that can be done using the gh_field.solvestep and gh_field.solvesteps methods. These use more math savvy methods like euler and runge-kutta to solve the differential problem, instead of just adding a tiny increment and iterating.
I've tried that methods...and the results are more like field lines (I suppose that David made it to solve field lines drawing). Try using then...I have try and the results are no the same (particles never return when energy is lost). Perhaps I need to try it harder :P
X.solvestep gives you a vector...not very usefull.
X.solvesteps gives you a point (but moving that points didn't look like particles in a field...perhaps I need more time to see how this works)
I'm rendering some images now. When finished I'll uoload the file with the euler solver configured instead the iterative one.
In the other hand, I have to revise the code because the vector addition have some "conceptual" problems.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by