bugpyFormex - Bugs: bug #40696, adding an Oriented Bounding Box in...

 
 

bug #40696: adding an Oriented Bounding Box in Coords

Submitted by:  francesco <francio>
Submitted on:  Mon 25 Nov 2013 08:09:50 AM UTC  
 
Category: CoreSeverity: 3 - Normal
Item Group: Feature requestStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 26 Nov 2013 10:26:24 AM UTC, comment #9:

Nothing wrong. The object is almost square. Principal axes are not a good way for orientation in such cases.

The OrientedBbox and PrincipalBbox may still be useful in many cases. A MinimalBbox might also be interesting (minimal volume, minimal surface).

Closing the bug.

Benedict Verhegghe <bverheg>
Project Administrator
Tue 26 Nov 2013 09:40:57 AM UTC, comment #8:

pick the file testobb.py (#29712) which takes as input block.pgf (#29711)

francesco <francio>
Project Member
Tue 26 Nov 2013 09:35:36 AM UTC, comment #7:

I cannot find the first attachment.

Benedict Verhegghe <bverheg>
Project Administrator
Mon 25 Nov 2013 06:59:50 PM UTC, comment #6:

The function does not produce the output I expected. in attachment a test code and a block.pgf mesh on which I get strange results. The function itself seems to give coherent results with the principal axis but the proincipal axis do ot appear to be correct. I checked the inertia functions and the seem ok. Any suggestions about this behaviour?

(file #29710, file #29711)

francesco <francio>
Project Member
Mon 25 Nov 2013 04:00:56 PM UTC, comment #5:

In commit 871afdb obbox and pobbox have been added in Coords
I shortened the name for convenience. i ll make more tests before closing the topic and add the same methods in Geometry

francesco <francio>
Project Member
Mon 25 Nov 2013 10:50:31 AM UTC, comment #4:

I would rather use the methods already applied in geometry_menu,
something along the following lines:

We should probably make a Coords.orientedBbox(ctr,rot) and a principalBbox() which calls orientedBbox with the inertia data.

Benedict Verhegghe <bverheg>
Project Administrator
Mon 25 Nov 2013 08:27:44 AM UTC, comment #3:

teh code is in attachment

(file #29703)

francesco <francio>
Project Member
Mon 25 Nov 2013 08:22:36 AM UTC, comment #2:
Benedict Verhegghe <bverheg>
Project Administrator
Mon 25 Nov 2013 08:13:18 AM UTC, comment #1:

Please include code between lines

or, if the code is large, attach it as a file.

Benedict Verhegghe <bverheg>
Project Administrator
Mon 25 Nov 2013 08:09:50 AM UTC, original submission:

I would like to include an oriented bounding box (based on the inertia) in coords, but I am not sure if it can be consistent with the current pyformex style. The advantage is that the bbox is smaller and better oriented with the points. this is the code I propose but can probably be improved.

def obb(coords):
from geomtools import intersectionPointsLWP
from plugins import inertia

C,I = inertia.inertia(coords)
inprin,inaxis = inertia.principal(I)
inaxis=inaxis.T
dmin=[]
dmax=[]
for i in range(3):
dtmp=intersectionPointsLWP(coords,resize(inaxis[i],coords.shape),C,inaxis[i],mode='pair')
dmin.append((length(dtmp-coords)*sign(inner((coords-dtmp),inaxis[i]))).min())
dmax.append((length(dtmp-coords)*sign(inner((coords-dtmp),inaxis[i]))).max())
dmax=asarray([dmax])
dmin=asarray([dmin])
b=(dmax-dmin).T*inaxis

crn0=C+(inaxis*dmin.T).sum(axis=0)
crn1=crn0+b[2]
crn2=crn0+b[2]+b[1]
crn3=crn0+b[1]
crn4=crn0+b[0]
crn5=crn0+b[0]+b[2]
crn6=crn0+b[0]+b[1]+b[2]
crn7=crn0+b[0]+b[1]
cbox=Coords(row_stack([crn0,crn1,crn2,crn3,crn4,crn5,crn6,crn7]))
ebox=arange(8)[None,:]
box=Mesh(cbox,ebox)
return box

francesco <francio>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #29712:  testobb.py added by francio (3KiB - text/x-python)
file #29711:  block.pgf added by francio (12KiB - application/octet-stream)
file #29703:  obb.py added by francio (920B - text/x-python)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bverheg (Posted a comment)
  • -unavailable- added by francio (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 26 Nov 2013 10:26:24 AM UTCbverhegStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Mon 25 Nov 2013 07:41:06 PM UTCfrancioAttached File-=>Added testobb.py, #29712
    Mon 25 Nov 2013 07:38:52 PM UTCfrancioAttached File#29710=>Removed
    Mon 25 Nov 2013 06:59:50 PM UTCfrancioAttached File-=>Added testobb.py, #29710
      Attached File-=>Added block.pgf, #29711
    Mon 25 Nov 2013 04:00:56 PM UTCfrancioStatusNone=>Ready For Test
    Mon 25 Nov 2013 08:27:44 AM UTCfrancioAttached File-=>Added obb.py, #29703

    Back to the top


    Powered by Savane 3.1-cleanup1