gabyx / ApproxMVBB

Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in 3D.
Mozilla Public License 2.0
441 stars 93 forks source link

Initial Matrix3Dyn from data #16

Closed pcpLiu closed 7 years ago

pcpLiu commented 7 years ago

Hey Gabyx,

I was trying to use your library to process some data in my research project, but I'm not very familiar with C++.

I'm trying to initial Matrix3Dyn from my 3D data points, but I'm not sure how to add point one by one. I searched your code base finding that Matrix3Dyn is a data structure wrapper of Eigen::Matrix from Eigen library (?). And I'm still confused how to use it after checking docs on Eigen.

Wonder if you could give some code fragments on this kind of usage? Thanks.

Tim

gabyx commented 7 years ago

Hi, of course :), for other example look at the approxMVBB examplea folder. the kdtree example

Von meinem iPhone gesendet

Am 16.02.2017 um 17:45 schrieb Zhonghao LIU notifications@github.com:

Hey Gabyx,

I was trying to use your library to process some data in my research project, but I'm not very familiar with C++.

I'm trying to initial Matrix3Dyn from my 3D data points, but I'm not sure how to add point one by one. I searched your code base finding that Matrix3Dyn is a data structure wrapper of Eigen::Matrix from Eigen library (?). And I'm still confused how to use it after checking docs on Eigen.

Wonder if you could give some code fragments on this kind of usage? Thanks.

Tim

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

gabyx commented 7 years ago

of course, you can write something like

Matrix3Dyn m(1000); to allocate a Matrix 3x1000 (I think) then you access each i-th point by m.col(i) = Vector3(1,2,3);

If you give me more information on your data and how it is saved (some code sample) I can give you an efficient way to map the memory of the points into an eigen3 matrix (by eigen::Map) .

you should always allocate memmory first an then write te points to the matrix, but you dont need to do that if you have a raw pointer into a plain c array. you map that directly into an eigen structure.

what kind of functions do you wanna use?

br gabriel

Von meinem iPhone gesendet

Am 16.02.2017 um 17:45 schrieb Zhonghao LIU notifications@github.com:

Hey Gabyx,

I was trying to use your library to process some data in my research project, but I'm not very familiar with C++.

I'm trying to initial Matrix3Dyn from my 3D data points, but I'm not sure how to add point one by one. I searched your code base finding that Matrix3Dyn is a data structure wrapper of Eigen::Matrix from Eigen library (?). And I'm still confused how to use it after checking docs on Eigen.

Wonder if you could give some code fragments on this kind of usage? Thanks.

Tim

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

pcpLiu commented 7 years ago

Thanks for the quick response!

Regarding of my research data, I have a file containing coords in format like:

x y z
x y z
.
.
.
x y z

My goal is to find the minimal volume boundary box.


Also I have q quick question, why only 2 diagonal points gave of the boundary box. Is it enough to identify the eight vertex of the box?

At last, forgive that I have some confusion about these introduction:

The returned object oriented bounding box oobb contains the lower oobb.m_minPoint and upper point oobb.m_maxPoint expressed in the coordinate frame K of the bounding box. The bounding box also stores the rotation matrix from the world frame to the object frame K as a quaternion oobb.m_q_KI . The rotation matrix R_KI from frame I to frame K can be obtained by oobb.m_q_KI.matrix() (see Eigen::Quaternion). This rotation matrix R_KI corresponds to a coordinate transformation A_IK which transforms coordinates from frame K to coordinates in frame I..

What is frame I? Do you mean world coordinate system? And I don't know why there are two coordinates systems here.

Thanks for your help!

pcpLiu commented 7 years ago

Also I have q quick question, why only 2 diagonal points gave of the boundary box. Is it enough to identify the eight vertex of the box?

For this question, is it because your algorithm giving Axis-aligned minimum bounding box? Initially, I think so but your displaying image seems not. I'm not sure.

gabyx commented 7 years ago

Ok, :-)

Since you are not familiar with C++ it gets a little bit harder, but, ok, first you need to read the CSV file (coma separated value file, the delimiter in your case is a simple "whitespace") into a matrix.

You are lucky, beacause I already read for the tests such files: see https://github.com/gabyx/ApproxMVBB/blob/master/tests/files/PointCloud_0.txt

on line: 226 in https://github.com/gabyx/ApproxMVBB/blob/master/tests/src/main_mvbbTests.cpp there is

auto v = getPointsFromFile3D(getFileInPath("Bunny.txt"));

which loads the file:
https://github.com/gabyx/ApproxMVBB/blob/master/tests/files/Bunny.txt with the function PointFunctions::Vector3List getPointsFromFile3D(std::string filePath) in https://github.com/gabyx/ApproxMVBB/blob/master/tests/src/TestFunctions.cpp

You can copy this function to your main.cpp and use it to get a PointFunctions::Vector3List (std::vector)

and then put it int a matrix:

auto v = getPointsFromFile3D(getFileInPath("Bunny.txt"));Matrix3Dyn t(3,v.size());for(unsignedint i = 0; i<v.size(); ++i) {t.col(i) = v[i]; }

This is far from optimal performant code but for a start probably easy to use.

The min point, max point, and the MVBB's coordinate system is enought o identify the box.

There is a function OOBB::getCornerPoints() which gives you all 8 points: https://github.com/gabyx/ApproxMVBB/blob/master/include/ApproxMVBB/OOBB.hpp line 153.

BR

------ Originalnachricht ------ Von: "Zhonghao LIU" notifications@github.com An: "gabyx/ApproxMVBB" ApproxMVBB@noreply.github.com Cc: "Gabriel Nützi" gnuetzi@gmail.com; "Comment" comment@noreply.github.com Gesendet: 17.02.2017 03:49:42 Betreff: Re: [gabyx/ApproxMVBB] Initial Matrix3Dyn from data (#16)

Thanks for the quick response!

Regarding of my research data, I have a file containing coords in format like:

x y z x y z . . . x y z My goal is to find the minimal volume boundary box.


Also I have q quick question, why only 2 diagonal points gave of the boundary box. Is it enough to identify the eight vertex of the box?

At last, forgive that I have some confusion about these introduction:

The returned object oriented bounding box oobb contains the lower oobb.m_minPoint and upper point oobb.m_maxPoint expressed in the coordinate frame K of the bounding box. The bounding box also stores the rotation matrix from the world frame to the object frame K as a quaternion oobb.m_q_KI . The rotation matrix R_KI from frame I to frame K can be obtained by oobb.m_q_KI.matrix() (see Eigen::Quaternion). This rotation matrix R_KI corresponds to a coordinate transformation A_IK which transforms coordinates from frame K to coordinates in frame I..

What is frame I? Do you mean world coordinate system? And I don't know why there are two coordinates systems here.

Thanks for your help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gabyx commented 7 years ago

Yes, frame I is the World Frame, I probably should mention that!

BR

------ Originalnachricht ------ Von: "Zhonghao LIU" notifications@github.com An: "gabyx/ApproxMVBB" ApproxMVBB@noreply.github.com Cc: "Gabriel Nützi" gnuetzi@gmail.com; "Comment" comment@noreply.github.com Gesendet: 17.02.2017 03:49:42 Betreff: Re: [gabyx/ApproxMVBB] Initial Matrix3Dyn from data (#16)

Thanks for the quick response!

Regarding of my research data, I have a file containing coords in format like:

x y z x y z . . . x y z My goal is to find the minimal volume boundary box.


Also I have q quick question, why only 2 diagonal points gave of the boundary box. Is it enough to identify the eight vertex of the box?

At last, forgive that I have some confusion about these introduction:

The returned object oriented bounding box oobb contains the lower oobb.m_minPoint and upper point oobb.m_maxPoint expressed in the coordinate frame K of the bounding box. The bounding box also stores the rotation matrix from the world frame to the object frame K as a quaternion oobb.m_q_KI . The rotation matrix R_KI from frame I to frame K can be obtained by oobb.m_q_KI.matrix() (see Eigen::Quaternion). This rotation matrix R_KI corresponds to a coordinate transformation A_IK which transforms coordinates from frame K to coordinates in frame I..

What is frame I? Do you mean world coordinate system? And I don't know why there are two coordinates systems here.

Thanks for your help!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

pcpLiu commented 7 years ago

Thanks Gabyx! Very helpful.

Just got a result from my data! Thanks for this excellent lib!

snapshot01_l00

gabyx commented 7 years ago

Looks good :-) Looks to me like some particle/atom studies? :-)

For what do you need the MVBB?

Am 17.02.2017 um 16:59 schrieb Zhonghao LIU notifications@github.com:

Thanks Gabyx! Very helpful.

Just running out of a result from my data! Thanks for the excellent lib!

https://cloud.githubusercontent.com/assets/3357328/23072563/226a2674-f500-11e6-9867-001f153dd704.png — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gabyx/ApproxMVBB/issues/16#issuecomment-280688961, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnhDU0JjACo_wo9qGQ9KK7hcibmMbTTks5rdcPcgaJpZM4MDQd-.

Gabriel Nützi MSc ETH Mechanical Engineering

gnuetzi@gmail.com +41 (0) 77 424 86 45

pcpLiu commented 7 years ago

It's about protein structure.

I generate some surface point for a protein and want to get a bounding box for further research