[GH/C#] Migrating bbox points

Does anyone have idea how to stabilize corners of box made from bbox?

I need box created based on axis and i need its corners but since they are dancing around they are pretty useless in my case…

@dale @pascal would you mind looking on this here and maybe you have some remedy for this?

migrating_bbox_points.gh (16.7 KB)

Here’s one without kangaroo counter (besides i forgot earlier internalise points):
migrating_bbox_points_nokan.gh (16.5 KB)

Nobody? Really no thoughts on this?

@clement @RIL @RadovanG maybe you guys have any idea how to lock those points?

If you work with the Box in plane coordinates, shouldn’t those vertices always stay the same (as the box rotates with the plane, and the min / max vertex is always the same one in relation to the plane) ?

@dsonntag they should. Would you mind provide example if you know how to achieve that? Rotating plane axis aren’t stable here also ( show preview of plane before bbox ). Second thing here is that box isn’t actually rotating but bbox is created each time and aligned to fit brep each time using changebasis ( like in this example - https://github.com/mcneel/rhino-developer-samples/blob/5/rhinocommon/cs/SampleCsCommands/SampleCsBoundingBox.cs)

Well, you figured it out, the plane is the problem :wink:

Just change the way it it constructed and if I understand it correctly it works ?!

migrating_bbox_points_modif.gh (24.3 KB)

Ok i get now whats your point here but i need to rotate this in all axis not only around x thats why i decided to create plane based on z axis. Cross product for y axis is obvious but how to calculate the perpendicular vector to z vector for x axis ?

I have in mind stable xaxis vector - Vector3d method PerpendicularTo() gives the same shifty result.

Well I guess the problem here is, that the orientation of xAxis and yAxis are not determined in that case (they can rotate arbitrarily around the plane normal, which I guess you already know :wink: ). Not sure I get what the larger plan is here?

@dsonntag larger plan here is to remap bitmap byte array to box base and then process it further but i can’t leave this to be arbitray pick :wink:

I meant, how is the movement of the box (or the plane, or the basic geometry) defined ?

z axis defines where plane should be pointing and to my logic x axis should be always to the right of z axis :slight_smile:

I think i found some quick dirty way to stabilize this. Of course theres for sure a lot of room for improvement on this.

migrating_bbox_points_modif2.gh (20.1 KB)

However i see that i’m missing something in the middle of the rotation? It looks like i’m missing somewhere 45 deg rot around zAxis…

Well thats even more interesting :face_with_monocle:

migrating_bbox_points_modif3.gh (20.7 KB)

… So which one is ‘proper’ ??

migrating_bbox_points_modif5.gh (24.2 KB)

@DavidRutten maybe you have some clue how this should be done?

I have not gone through all the examples, but if your goal is to rotate a plane in space, why not apply rotations to a plane in the first place? Or construct a plane in the beginning and then use the transformation info from the rotations and apply it to the plane?

That is solution.
migrating_bbox_points_modif6.gh (29.6 KB)

@RadovanG thank you very much for input on this. Your idea is indeed good but the thing is that this cone should stay on its place because i need bbox of it but bbox needs to be oriented along normal axis (so bbox is changing basis from world to custom coord system - like in example from @dale in post no.4) the cone itself should NOT move :wink:

I tried to reverse your idea but if i get it correctly it behaves that way cause of change basis matrix ?
migrating_bbox_points_modif7.gh (18.0 KB)

Is this what you are after?

migrating_bbox_points_ds.gh (11.6 KB)

I’m not sure this time because this part with rotation was just to show that when vector is different then bbox base points are going nuts - i think it is similar solution to this from modif5 file where i was rotating plane in c# block ( called Custom Plane Rotation ) isn’t it the same approach?

Probably, I have not gone through all the solutions in the various C# scripts…

I guess I still don’t get what you want to do, and where your problem is, sorry. As far as I understood you wanted to track the corner vertices of a moving bounding box, which actually never was a problem in the first place, as it was only a result of the way the orientation plane of the bounding box was constructed.

@dsonntag In general:

I need to create bbox aligned to object based on one axis and from this bbox i get corners which i need to define xy axis for bitmap mapping. But when axis is changing for eg. from vec = 0,0,1 to vec = 0.25,0.25,1 (i wrote here arbitrary numbers just for eg.) corners of bbox are fliping mirroring etc.

Hmm in my opinion the problem is mathmatically underdefined… your plane can arbitraryly rotate around the normal axis, thus at least the numbering of the 4 top corners and the 4 bottom corners of your derived bounding box will always be arbitrary (feel free to prove me wrong :wink: )
Any chance you can track the movement of the vector? In that case attach the plane to the vector or apply this movement to plane…

First of all, it is good not to use misleading terms - bbox aligned to object is not correct term. BBox of a geometry is aligned to a plane so bbox is defined by the geometry and “aligned” plane.
Here is solution where geometry (object) stays still and plane is rotating.
migrating_bbox_points_modif7.gh (28.6 KB)

1 Like

I understand that my explanation was misleading probably however now when you use those rotations it works as i would predict however i have still only one vector as an input so i’m trying to reverse that from Vector angles to get desired plane but without luck - for sure i don’t understand something here…

@RadovanG would you mind to take a look on code in those two top c# components? I’m not sure why i’m still getting different results :frowning:

migrating_bbox_points_modif8.gh (25.8 KB)