Box Reorder Challenge

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  1 Week Ago
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
  1 Week Ago
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.
Proin3D YouTube Channel
  6 Days Ago
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...

[90° X-Rot Matrix]•[]•[90° X-Rot Matrix]^(-1)

Last edited by Archangel35757 : 6 Days Ago at 11:55 PM.
  6 Days Ago about just re-orienting the 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.
  6 Days Ago
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.
Proin3D YouTube Channel
  2 Days Ago
Without additional information, this is my proposal (few maths here):

   -- Set Scene
   delete objects
   bb = box Width:15 Length:5 Height:10
   about 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 =; 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.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.
Proin3D YouTube Channel
reply share thread

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
Society of Digital Artists

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 05:12 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.