algorithmic modeling for Rhino
Hi everyone,
does anyone have an idea how to convert the concept "Minimize serial rotation" (indeed, the discription of the Align Planes component) to a (VB) script? I need to 'align' my planes but I can't even come up with a pseudo code for that.
I guess serial rotation means rotation in local X direction, then rotation in Y direction and then rotation in Z direction all added up, but how would one minimize all that?
Since the original discussion had plenty viewers but no replies, I'm guessing this is a tough one...
Can anyone give a pointer please?
Kind regards,
Pieter
Tags:
I'm pretty sure that the Align Plane and Align Planes components do not change the Normal of the Plane being Aligned only bringing one of the axis into the same projected direction
You're right Danny, and thanks, that is a good pointer. (At least) one variable eliminated. I'm going to try something with that knowledge.
Pieter
Have some fun with this (I do hope that GH internalized the curve).
Q: Which Plane is the best?
A: The Ducati Plane, he he
best, Peter
Thanks for your input Peter, I couldn't recognize the alignment vector in your code though.
B.t.w.: When I put it through the converter I ended up with a bunch of renamed variables, that obviously crippled the code. In this battle the planes won...
Well... in fact my intention (behind the lines, he he) was to outline "some" issues with the Rhino SDK as regards making "stable" Planes (name is unfortunate: Coordinate Systems anyone?).
What issues may you ask. Well ... set project = true and watch the yellow axis (FrameAt Plane) dancing even with a "flat" curve on hand ...
Get the updated Planes VS us thing.
Get 2 quite indicative Plane tests as well posted a million years ago (in the prehistoric days, he he) that indicate the obvious (chaos, that is). DotProduct is used to filter good/bad things.
best, Peter
Hi Peter, thanks for your input again, but there's too much going on for me to filter out the crux to my question, if it's in there. Though I really appreciate your humor, it does make it harder for me to see what you are doing, even though your definitions are nicely organised (thumbs up for that).
But I think you may want to start your own discussion to get an answer to your SDK issues questions, not? I have a feeling the answer to them is also the align planes component, but as I said I'm not sure I understand what you are asking...
Thanks for the Fireblade offer, but I'm pretty sure it'll kill me so no thank you. Bikes have already attempted that... even though I am dutch ~:/
the logic seems simple enough - project the alignment vector to the plane, then construct a new plane with the same origin, with the projected vector as X and the cross product between the original normal and the new X as Y.
Thank you Andrew, indeed you got the pseudocode correct:)
This is what I'll be working with. Thanks a lot!
It's just this, yes?
' Where P1 is the plane to reorient
' and the X Axis of P2 is the driving vector
Dim RotateAngle As Double = Vector3d.VectorAngle(P1.XAxis, P2.XAxis, P1)
P1.Rotate(RotateAngle, P1.ZAxis)
A = P1
:) Yes it is, great! thanks a lot David, and it's super concise too.
I only replaced the P2.XAxis with my alignment vector.
I'll still finish my own approach (well, Andrew's that is) now as an exercize, but I bet I can't beat this.
Thank you David.
This is is my translation of Andrews' pseudo code. I think it's actually a tiny bit faster, though not as concise:
Private Sub RunScript(ByVal P As Plane, ByVal D As Vector3d, ByRef F As Object)
Dim alignmentLine As Line = New Line(P.Origin, D, 1)
Dim alignmentLineProjected As Line = New Line(P.Origin, P.ClosestPoint(alignmentLine.PointAt(1)))
Dim alignmentLineProjectedVect As Vector3d = New Vector3d(alignmentLineProjected.Direction)
alignmentLineProjectedVect.Unitize()
Dim alignedPlane As Plane = New Plane(P.Origin, alignmentLineProjectedVect, Vector3d.CrossProduct(P.ZAxis, alignmentLineProjectedVect))
F = alignedPlane
End Sub
Nice! That looks good. Yeah, the angle and rotation calculations are definitely more computationally expensive, although you could do it all in one line: P1.Rotate(Vector3d.VectorAngle(P1.XAxis, P2.XAxis, P1), P1.ZAxis) :)
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