pboechat / pyobb Goto Github PK
View Code? Open in Web Editor NEWOBB implementation in python (using numpy)
License: MIT License
OBB implementation in python (using numpy)
License: MIT License
Hi, I am new learner of 3d geometry. Your tool helps me a a lot to get oriented bounding box. But I don't know how to visualize it like what to show in the README.md. Could you give me some hints or url sources to guide me how to visualize it?
For all these following:
centroid: the OBB center
min: the OBB point with the smallest XYZ components
max: the OBB point with the largest XYZ components
points: the 8 points of the OBB
extents: the extents of the OBB in the XYZ-axis
Are they based on the local frame of reference, or the global frame of reference?
I am kinda confused.
And should I use rotation.T as the base vector of OBB, and take the centroid as the origin of the local frame of reference?
I noticed that in certain cases, one of the vertices is wrong.
From the code below, I have represented in yellow an array of coordinates of points while the vertices of the obb are green.
spond to the points I got from the obb object constructed from the yellow dots
The last vertex is not correct.
Please find attached a MWE
Sorry for the length of the code.
`
import numpy as np
from numpy import array
from mayavi import mlab
from pyobb.obb import OBB
Pts =
array([[ 0.3 , 0.6012 , -0.5 ],
[ 0.22981333, 0.66547876, -0.5 ],
[ 0.05209445, 0.69968078, -0.5 ],
[-0.15 , 0.68780254, -0.5 ],
[-0.28190779, 0.63540201, -0.5 ],
[-0.28190779, 0.56699799, -0.5 ],
[-0.15 , 0.51459746, -0.5 ],
[ 0.05209445, 0.50271922, -0.5 ],
[ 0.22981333, 0.53692124, -0.5 ],
[ 0.3 , 0.6012 , -0.5 ],
[ 0.3 , 0.6012 , -0.36200274],
[ 0.22981333, 0.66547876, -0.36200274],
[ 0.05209445, 0.69968078, -0.36200274],
[-0.15 , 0.68780254, -0.36200274],
[-0.28190779, 0.63540201, -0.36200274],
[-0.28190779, 0.56699799, -0.36200274],
[-0.15 , 0.51459746, -0.36200274],
[ 0.05209445, 0.50271922, -0.36200274],
[ 0.22981333, 0.53692124, -0.36200274],
[ 0.3 , 0.6012 , -0.36200274],
[ 0.3 , 0.6012 , -0.2441701 ],
[ 0.22981333, 0.66547876, -0.2441701 ],
[ 0.05209445, 0.69968078, -0.2441701 ],
[-0.15 , 0.68780254, -0.2441701 ],
[-0.28190779, 0.63540201, -0.2441701 ],
[-0.28190779, 0.56699799, -0.2441701 ],
[-0.15 , 0.51459746, -0.2441701 ],
[ 0.05209445, 0.50271922, -0.2441701 ],
[ 0.22981333, 0.53692124, -0.2441701 ],
[ 0.3 , 0.6012 , -0.2441701 ],
[ 0.3 , 0.6012 , -0.14074074],
[ 0.22981333, 0.66547876, -0.14074074],
[ 0.05209445, 0.69968078, -0.14074074],
[-0.15 , 0.68780254, -0.14074074],
[-0.28190779, 0.63540201, -0.14074074],
[-0.28190779, 0.56699799, -0.14074074],
[-0.15 , 0.51459746, -0.14074074],
[ 0.05209445, 0.50271922, -0.14074074],
[ 0.22981333, 0.53692124, -0.14074074],
[ 0.3 , 0.6012 , -0.14074074],
[ 0.3 , 0.6012 , -0.04595336],
[ 0.22981333, 0.66547876, -0.04595336],
[ 0.05209445, 0.69968078, -0.04595336],
[-0.15 , 0.68780254, -0.04595336],
[-0.28190779, 0.63540201, -0.04595336],
[-0.28190779, 0.56699799, -0.04595336],
[-0.15 , 0.51459746, -0.04595336],
[ 0.05209445, 0.50271922, -0.04595336],
[ 0.22981333, 0.53692124, -0.04595336],
[ 0.3 , 0.6012 , -0.04595336],
[ 0.3 , 0.6012 , 0.04595336],
[ 0.22981333, 0.66547876, 0.04595336],
[ 0.05209445, 0.69968078, 0.04595336],
[-0.15 , 0.68780254, 0.04595336],
[-0.28190779, 0.63540201, 0.04595336],
[-0.28190779, 0.56699799, 0.04595336],
[-0.15 , 0.51459746, 0.04595336],
[ 0.05209445, 0.50271922, 0.04595336],
[ 0.22981333, 0.53692124, 0.04595336],
[ 0.3 , 0.6012 , 0.04595336],
[ 0.3 , 0.6012 , 0.14074074],
[ 0.22981333, 0.66547876, 0.14074074],
[ 0.05209445, 0.69968078, 0.14074074],
[-0.15 , 0.68780254, 0.14074074],
[-0.28190779, 0.63540201, 0.14074074],
[-0.28190779, 0.56699799, 0.14074074],
[-0.15 , 0.51459746, 0.14074074],
[ 0.05209445, 0.50271922, 0.14074074],
[ 0.22981333, 0.53692124, 0.14074074],
[ 0.3 , 0.6012 , 0.14074074],
[ 0.3 , 0.6012 , 0.2441701 ],
[ 0.22981333, 0.66547876, 0.2441701 ],
[ 0.05209445, 0.69968078, 0.2441701 ],
[-0.15 , 0.68780254, 0.2441701 ],
[-0.28190779, 0.63540201, 0.2441701 ],
[-0.28190779, 0.56699799, 0.2441701 ],
[-0.15 , 0.51459746, 0.2441701 ],
[ 0.05209445, 0.50271922, 0.2441701 ],
[ 0.22981333, 0.53692124, 0.2441701 ],
[ 0.3 , 0.6012 , 0.2441701 ],
[ 0.3 , 0.6012 , 0.36200274],
[ 0.22981333, 0.66547876, 0.36200274],
[ 0.05209445, 0.69968078, 0.36200274],
[-0.15 , 0.68780254, 0.36200274],
[-0.28190779, 0.63540201, 0.36200274],
[-0.28190779, 0.56699799, 0.36200274],
[-0.15 , 0.51459746, 0.36200274],
[ 0.05209445, 0.50271922, 0.36200274],
[ 0.22981333, 0.53692124, 0.36200274],
[ 0.3 , 0.6012 , 0.36200274],
[ 0.3 , 0.6012 , 0.5 ],
[ 0.22981333, 0.66547876, 0.5 ],
[ 0.05209445, 0.69968078, 0.5 ],
[-0.15 , 0.68780254, 0.5 ],
[-0.28190779, 0.63540201, 0.5 ],
[-0.28190779, 0.56699799, 0.5 ],
[-0.15 , 0.51459746, 0.5 ],
[ 0.05209445, 0.50271922, 0.5 ],
[ 0.22981333, 0.53692124, 0.5 ],
[ 0.3 , 0.6012 , 0.5 ]])
mlab.points3d(Pts[:,0],
Pts[:,1],
Pts[:,2],
color = (1.,1.,0.))
obb = OBB.build_from_points(Pts)
"""
get the vertices of the obb
"""
vertices = np.concatenate(obb.points).reshape(-1,3)
mlab.points3d(vertices[:,0],
vertices[:,1],
vertices[:,2],
color = (0.,1.,0.))
`
how can i get output points(obb vertices points: the 8 points of the OBB)?
Attached the obj file
Executed with demo python file (bin/pyobb_demos/3d_demo.py)
Thanks
Vishnu C
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.