generative modeling for Rhino
I'm trying to orient a list of points from one coordinate system to another.
There are 7 points and 7 planes. I just want to take the first 6 points and orient them from the first 6 planes to the last 6 planes.
point(0) oriented from plane(0) to plane(1)
point(1) oriented from plane(1) to plane(2)
Unfortunately changeBasis is giving me some trouble. I'm sure I'm doing something wrong. See script below (some of the script is just there for me to verify that the inputs are exactly the same between the component version and the scripted version. I've grayed this stuff out). The bottom panels in the screenshot show that there are differing result between the two operations.
Private Sub RunScript(ByVal Plns As DataTree(Of Plane), ByVal Pts As List(Of Point3d), ByVal adj As List(Of Double), ByRef Orient As Object, ByRef A As Object, ByRef B As Object, ByRef C As Object)
Dim orientPts As New List(Of Point3d)
Dim plnList1 As New List(Of Plane)
Dim plnList2 As New List(Of Plane)
Dim ptList As New list(Of point3d)
For i As Integer = 0 To Pts.count - 2
plnList2.add(Plns.Branch(1).item(i + 1))
Dim newPt As Point3d = Pts(i)
Orient = orientPts
'Just to show these input are the same as the GH version
A = ptList
B = plnList1
C = plnList2
Here's an example file
ChangeBasis performs mapping from one plane system to another. I think you want to map points defined in world coordinates from one (non-world) plane to another (non-world) plane. This requires 2 ChangeBasis transformations:
Dim WA As Transform = Transform.ChangeBasis(Plane.WorldXY, plnList1(i))
Dim BW As Transform = Transform.ChangeBasis(plnList2(i), Plane.WorldXY)
Dim XF As Transform = BW * WA
By multiplying the transforms you can then get away with only a single transformation. This doesn't really give you much performance increase for points, but when transforming curves or meshes or breps it can drastically speed up the process.