
Hello, By looking at the documentation I can see that Geometry library is great for 2D polygons. I am working in 3D, so I wanted to ask about what I can, and what I can't. Is it possible to define 3D shapes, calculate their intersections, unions and so on? What about centroids and second (geometrical) moments of inertia? Does the geometry deal with spheres, or maybe other classical 3D geometries, like ellipsoid, torus or cone? What about the infinite geometries (like infinite cone)? Or infinitely long line? Also I wanted to ask about 3D points regarded as vectors. Can I add and subtract them? What about 3D vector cross product. What about dot product? I guess that I need to write that 'very old formula' function myself? In fact, since you are well into the subject, perhaps you could tell me if there are anywhere in boost a vector dot product and cross product implemented? Last but not least - I am doing frequently a 3D rotation of 3D points using quaternions for that (this could work with rotation matrices too). I suppose that I would need to implement this myself to "link" boost::quaternion with boost::geometry::point3d. please enlighten me and thank you very much for your time -- Janek Kozicki http://janek.kozicki.pl/ |

Hi Janek,
By looking at the documentation I can see that Geometry library is great for 2D polygons. I am working in 3D, so I wanted to ask about what I can, and what I can't. Is it possible to define 3D shapes, calculate their intersections, unions and so on? What about centroids and second (geometrical) moments of inertia?
No. The 3D is implemented in the design but there is hardly any implementation. 3D points and boxes can be defined. 3D distances can be calculated. There is some more but the operations you ask for are not yet implemented.
Does the geometry deal with spheres, or maybe other classical 3D geometries, like ellipsoid, torus or cone? What about the infinite geometries (like infinite cone)? Or infinitely long line?
The sphere is moved to an extension. The other geometries you mention are not (yet) there. We concentrate on finishing the part for first inclusion into Boost first.
Also I wanted to ask about 3D points regarded as vectors. Can I add and subtract them? What about 3D vector cross product. What about dot product? I guess that I need to write that 'very old formula' function myself?
This is possible: seeing 3D points as vectors, adding and subtracting indeed. Dot product in any dimension; cross product in 2 and 3 dimensions.
In fact, since you are well into the subject, perhaps you could tell me if there are anywhere in boost a vector dot product and cross product implemented?
I know that Emil's library of which I hope it is reviewed soon does have it: http://www.revergestudios.com/boost-la/ If accepted, we plan to merge vector operations / let them interoperate between geometries.
Last but not least - I am doing frequently a 3D rotation of 3D points using quaternions for that (this could work with rotation matrices too). I suppose that I would need to implement this myself to "link" boost::quaternion with boost::geometry::point3d.
I've rotated 3D shapes (linestrings) using the transformations, delivering a KML shape like here <http://www.xs4all.nl/~barend/geodan/poisonous_cloud.png> and here <http://www.xs4all.nl/~barend/geodan/ve_mal.htm>. So these things should be possible, however the calculation of the rotation about an arbitrary axis was in draft and not yet in the SVN. If wished I can add this once. On the other hand a link with boost::quaternion sounds also as an attractive alternative. Regards, Barend

On Fri, Apr 23, 2010 at 12:19 AM, Barend Gehrels <barend@geodan.nl> wrote:
In fact, since you are well into the subject, perhaps you could tell me if there are anywhere in boost a vector dot product and cross product implemented?
I know that Emil's library of which I hope it is reviewed soon does have it:
http://www.revergestudios.com/boost-la/
If accepted, we plan to merge vector operations / let them interoperate between geometries.
For Janek's sake, you just define a simple traits type for any vector type, and the generic vector operations in (Boost) LA kick-in automatically.
Last but not least - I am doing frequently a 3D rotation of 3D points using quaternions for that (this could work with rotation matrices too). I suppose that I would need to implement this myself to "link" boost::quaternion with boost::geometry::point3d.
I've also implemented generic quaternion operations in (Boost) LA that kick-in for user-defined types, but I haven't yet published that code because I haven't got a chance to update the documentation. Hopefully soon. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

Emil Dotchevski said: (by the date of Fri, 23 Apr 2010 00:55:33 -0700)
On Fri, Apr 23, 2010 at 12:19 AM, Barend Gehrels <barend@geodan.nl> wrote:
http://www.revergestudios.com/boost-la/ If accepted, we plan to merge vector operations / let them interoperate between geometries.
For Janek's sake, you just define a simple traits type for any vector type, and the generic vector operations in (Boost) LA kick-in automatically.
Last but not least - I am doing frequently a 3D rotation of 3D points using quaternions for that (this could work with rotation matrices too). I suppose that I would need to implement this myself to "link" boost::quaternion with boost::geometry::point3d.
I've also implemented generic quaternion operations in (Boost) LA that kick-in for user-defined types, but I haven't yet published that code because I haven't got a chance to update the documentation. Hopefully soon.
Many thanks for your answers. Currently I have boost 1.42 installed. I can download your libraries and put them in include/ directory (are those include only?). So I can use them. But can they work for me? To answer this, could you tell me how such a "very simple" program using your libraries could look? Full source is in the attachment. (I am using currently some parts of WildMagic 3 library,which is under LGPL license). Here's the simple program (full version in attachment): #include <iostream> #include <string.h> #include "Vector3.hpp" #include "Quaternion.hpp" using namespace std; int main() { Vector3d a,b,c; // declare some 3D vectors a = Vector3d( 0.0 , 0.0 , 1.0 ); // initialize them somehow b = Vector3d( 0.0 , 0.0 , -1.0 ); c = Vector3d( 0.0 , 2.0 , 0.0 ); cout << "\ndeclared 3D vectors:\n"; cout << "a: " << a << "\n"; cout << "b: " << b << "\n"; cout << "c: " << c << "\n"; cout << "a + c: " << a+c << endl; // vector addition test cout << "a x c: " << a.cross(c) << endl; // vector cross product test cout << "a . b: " << a.dot(b) << endl; // vector dot product test Quaterniond q; // declare some quaternion q.align(b,a); // now quaternion q will describe a rotation from vector a to vector b cout << "\nquaternion q (which rotates vector a into vector b): " << q << endl; Vector3d axis; double angle; q.toAxisAngle(axis,angle); // now, represent this rotation q as an axis-angle pair cout << "axis of rotation: " << axis << " angle of rotation: " << angle << endl; cout << "So now, let's rotate a by quaternion q, did we get b from that?\n"; cout << "q*a: " << q*a << endl; cout << "b: " << b << endl; }; // program output: // // declared 3D vectors: // a: 0 0 1 // b: 0 0 -1 // c: 0 2 0 // a + c: 0 2 1 // a x c: -2 0 0 // a . b: -1 // // quaternion q (which rotates vector a into vector b): 0 0 -1 0 // axis of rotation: 0 -1 0 angle of rotation: 3.14159 // So now, let's rotate a by quaternion q, did we get b from that? // q*a: 0 0 -1 // b: 0 0 -1 Once I have figured out how to do above code using boost + your libraries only, I will be very happy to switch to boost entirely. Also - I will be very happy to test your library and submit bug reports or patches, but let's get this simple example to work first. Composing rotations by multiplying quaternions should work too. And normalizing them, conjugating, inverting, etc, but all that is already in boost::quaternion. best regards -- Janek Kozicki http://janek.kozicki.pl/ |

Barend Gehrels said: (by the date of Fri, 23 Apr 2010 09:19:51 +0200)
No. The 3D is implemented in the design but there is hardly any implementation. 3D points and boxes can be defined. 3D distances can be calculated. There is some more but the operations you ask for are not yet implemented.
The sphere is moved to an extension. The other geometries you mention are not (yet) there. We concentrate on finishing the part for first inclusion into Boost first.
I see. I asked to get the picture about current state of matters. Now that it is as you tell me, I think that the best thing for me, is to focus on 3d vectors and quaternions. I'll be implementing the 3D shapes on my own, as I need them. (I have plenty of old code with such things, lying around, but never enough time to clean it up).
Also I wanted to ask about 3D points regarded as vectors. Can I add and subtract them? What about 3D vector cross product. What about dot product? I guess that I need to write that 'very old formula' function myself?
This is possible: seeing 3D points as vectors, adding and subtracting indeed. Dot product in any dimension; cross product in 2 and 3 dimensions.
this would be great. From Emil's answer I hope that this in fact already is going to work. See my other reply that I've just sent.
So these things should be possible, however the calculation of the rotation about an arbitrary axis was in draft and not yet in the SVN. If wished I can add this once. On the other hand a link with boost::quaternion sounds also as an attractive alternative.
I believe that using boost::quaternion is the best way to go. Maybe Emil's extensions to it are just enough? -- Janek Kozicki http://janek.kozicki.pl/ |
participants (3)
-
Barend Gehrels
-
Emil Dotchevski
-
Janek Kozicki