I intend to create a C extension for lots of geometric manipulations. I definitely need functions for finding intersections between planes, edges, faces, etc.

Are there functions lurking in the API for this? Or maybe there is a library somewhere I can load and compute this myself? Maybe there are external libraries that people use?

According to the website, it is header file based (I guess that means C++ templates everywhere). It seems to consist of numerous header files.

I thought at one time that a library like that could have its routines accelerated with the graphics card. If it is header files only, I don’t know if it would call the OpenGL routines that access a graphics card (OpenGL is an open specification, but the graphics driver source code is proprietary to the graphics card manufacturers).

It is more of a mathematician or engineer tool kit that supports matrices of any dimensions (which uses complex templates everywhere). It doesn’t cleanly match up with Sketchup’s GEOM module.

I wonder if the Sketchup develop team created their GEOM module from scratch, or if it was based off of an existing library?

It just means the library itself does not need compiled. No binary is generated to link against. You just need to include the headers in order to make the functions available in your compiled extension.

As far as libraries, libigl does matrices, but also a lot of other neat stuff and looks like it might be a good fit for SketchUp. Something like Dual quaternion skinning would be amazing for SketchUp, for example.

Thanks for all those suggestions. I had a look through each (though yet to be tested).

This looks right up my street. It seems to marry up to Sketchup’s geometry system well. Thank you for this! Performance-wise, I am sure it will beat using Ruby methods from C, so that’s a win.

I think this library is primarily intended for rendering applications. I can’t find much in the way of geometry manipulations here.

This seems quite promising, and I bet it is quick, being made for mathematicians / engineers. However, I didn’t immediately understand the documentation as well as MathsGeoLib.

It’s used in ‘dilay’ for geometry creation and manipulation… [ Jim posted a link Dilay for the other day ]
I started building a mac port, but had trouble linking GLM in…
I think I need to build it as a linked Library on a mac…

I’ve been looking into the MathsGeoLib some more. I like how it looks. I have one concern, however.

MathsGeoLib uses float numbers as the basis of the vectors. As far as I can understand, Sketchup uses double numbers, which as I understand has twice the precision. Have you had issues with prevision? As my manipulations need to make sure edges need to meet and edges of faces have to meet others, I am a little concerned by this. Have you experienced any issues in regards to precision before?

I don’t think I have had issues with precision. But I’m only generating transformations for placing components, not raw edges/faces.
Sketchup’s tolerance is 1/1000", is a C float more precise that 0.001? I think so.

You should try to have MathsGeoLib work on a complicated/tricky case and see if it’s precise enough.

A C float number gives around 7 “significant figures” of precision from what I have read. That means that I can achieve the 1/1000" (0.001") tolerance/accuracy for lengths of up to 9999" (9999.999"), or 254m (this is a simplification, I understand, as binary numbers don’t match perfectly to decimals). Any sizes larger than this, and I guess the numbers will start to truncate and become inaccurate.

I guess this is enough precision for most architectural scales. I would have liked an extra couple of digits to reassure me.

That said, I will give MathGeoLib a go. It definitely feels the most friendly to me.

I’ve had a look already. Floats are very much tangled into the code. There might be a way to do lots of regex find/replace though, if there are only a few source files that are required.

4 months into learning C++, I’ve ended up putting together my own library for Vector maths that plugs in nicely with SketchUp. I realised that it wasn’t that hard to do, and in fact much quicker than using an external library for what I wanted to do. I was surprised how few functions were required to cover most vector calculations (+, -, *, /, dot product, cross product, covered most). Going through the code of MathsGeoLib really helped me as a reference.

I’ve included the text for the header file for my library below in case anyone is interested. I’d be happy to share once it’s more polished and complete. The great advantage of my custom library is being able to quickly start calculating using SketchUp’s native structs that hold geometric data:
e.g Vector3D a = Point3D(SUPoint3D c) - Point3D(SUPoint3D b)); // This needs 3 lines of code with MathGeoLib