# Box Reorder Challenge

 6 Days Ago denisT MAX Doctor   portfolio Denis Trofimov CA, USA Box Reorder Challenge I met an interesting problem. I had a fun solving it.. And I think it might be interesting  for someone who want to practice in logic and math Here is the task: #1 we have a Box object by default Width is X, Length is Y axis,  and Height is Z we need to re-orient the box where by order (XYZ, XZY, YXZ, YZX, ZXY, ZYX)  is specified dimensions (shortest ,  medium, longest) for example XYZ means: X-shortest, Y - medium, Z - longest of course after re-ordeing object has to keep it's shape and view position and orientation share quote
 5 Days Ago aaandres Copy-Paster   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España Sorry but I can't understand the challenge. You talk about "re-orient" and about "re-order", and only with a box that must keep it's shape, view and orientation. I can not imagine what you mean. __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
 5 Days Ago Archangel35757 Expert portfolio Michael Lawler Engineer Madison, USA I understood him to say... change the X, Y, Z values of the box... then you have to re-orient (rotate the box) such that it appears exactly the same as before your change.  So if you select the box you will see it's local axes changing yet it maintains the same visual appearance. The XYZ "order" is changing but it is always: [shortest, medium, longest] My guess would be to use coordinate transformation on the box to the "new" coordinate system.  This should keep the look and world position the same. For example... to go from XYZ to XZY... we observe this is a +90 degree rotation about the X-axis...  so: [90° X-Rot Matrix]•[XYZBox.tm]•[90° X-Rot Matrix]^(-1) Last edited by Archangel35757 : 5 Days Ago at 11:55 PM. share quote
 5 Days Ago vusta Expert vu nguyen ...under a rock, Australia dunno...how about just re-orienting the pivot...ie. you don't have to worry about re-orienting the box afterwards. So the box looks exactly the same, nothing has moved...but if you reorient the pivot, effectively the local axis (dims) have changed. share quote
 4 Days Ago aaandres Copy-Paster   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España What about the pivot? It must stay at its relative position after rotations or should it move to its original world position? __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote
 20 Hours Ago aaandres Copy-Paster   portfolio Andres Fernandez Cruz Proin3D CEO Proin3D Madrid, España Without additional information, this is my proposal (few maths here): `````` ( -- Set Scene delete objects bb = box Width:15 Length:5 Height:10 about bb.center rotate bb (eulerAngles 30 15 0) bb2 = copy bb -- Test box -- Reorder/Reorient -- orders = #(#XYZ, #XZY, #YXZ, #YZX, #ZXY, #ZYX) a = bb.width; b = bb.length; c = bb.height center = bb.center; pos = bb.pos angleX = angleY = angleZ = 0 order = 1 if a > b then (order = 3; swap a b; angleZ = 90) if b > c then (order +=1; swap b c; angleX = 90; if a > b then (swap a b; order += 3; angleY = 90)) if order > 6 do order = 6 bb.width = a; bb.length = b; bb.height = c bb.pivot = bb.center; bb.pos = center rot = eulerangles angleX angleY angleZ in coordsys local  rotate bb rot bb.pivot = pos -- pivot to its original position format "width= %; length= %; height= %\n" bb.width bb.length bb.height )`````` __________________ Andrés FC. P3D_PathScripts Proin3D YouTube Channel share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.