Grasshopper

algorithmic 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)

etc.

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
plnList1.add(Plns.Branch(1).item(i))
plnList2.add(Plns.Branch(1).item(i + 1))
ptList.add(Pts(i))

Dim newPt As Point3d = Pts(i)
newPt.transform(transform.ChangeBasis(plnList1(i), plnList2(i)))
orientPts.add(newPt)

Next

Orient = orientPts

'Just to show these input are the same as the GH version
A = ptList
B = plnList1
C = plnList2

End Sub

Views: 538

Attachments:

Replies to This Discussion

Here's an example file

Attachments:

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:

  1. Map world points into Plane A system (this gives you xyz->uvw for plane A)
  2. Map uw points in Plane B system back into world points

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.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service