I have 4 Rhino points (Origin, X, Y, and Z) that I’m using to define a plane. The problem is that when they are mirrored across the X or Y, the Z vector of the plane becomes inverted. I can check for the invert by comparing the vector of Origin to Z against the Z vector from PlaneFromPoints(Origin, X, Y) .
- Is it valid to just swap out the plane’s z vector with the correct value?
- What’s the correct way to create the correct plane?
- How are the zero values in a vector negative?
See code below:
Sub HelpMyPlanesInverted()
Dim pts(3), mirrorPts(3), plane, i, xform, vector
pts(0) = Array(5, 5, 5) 'origin'
pts(1) = Array(6, 5, 5) 'x'
pts(2) = Array(5, 6, 5) 'y'
pts(3) = Array(5, 5, 6) 'z'
plane = Rhino.PlaneFromPoints(pts(0), pts(1), pts(2))
Print "Correct Plane:", plane
' Correct Plane:'
' 5.000, 5.000, 5.000 '
' 1.000, 0.000, 0.000 '
' 0.000, 1.000, -0.000'
' - 0.000, 0.000, 1.000'
xform = Rhino.XformMirror(Array(0, 0, 0), Array(1, 0, 0))
For i = 0 To 3
mirrorPts(i) = Rhino.PointTransform(pts(i), xform)
Next
Print "Mirrored Pts:", mirrorPts
' Mirrored Pts:'
' - 5.000, 5.000, 5.000 '
' - 6.000, 5.000, 5.000 '
' - 5.000, 6.000, 5.000 '
' - 5.000, 5.000, 6.000 '
plane = Rhino.PlaneFromPoints(mirrorPts(0), mirrorPts(1), mirrorPts(2))
Print "Upside down plane:", plane
' Upside down plane:'
' -5.000, 5.000, 5.000'
' - 1.000, 0.000, 0.000'
' 0.000, 1.000, -0.000 '
' - 0.000, -0.000, -1.000 '
vector = Rhino.VectorCreate(pts(3), pts(0))
plane(3) = vector
Print "Is this a valid plane?", plane
' Is this a valid plane?'
' -5.000, 5.000, 5.000 '
' - 1.000, 0.000, 0.000'
' 0.000, 1.000, -0.000 '
' 0.000, 0.000, 1.000 '
End Sub
Sub Print(label, pts)
Rhino.Print label
Dim pt
For Each pt In pts
Rhino.Print Rhino.Pt2Str(pt, , True)
Next
End Sub