Information about CGAL and alternatives
13:01 10 May 2020

I'm working on a problem that will eventually run in an embedded microcontroller (ESP8266). I need to perform some fairly simple operations on linear equations. I don't need much, but do need to be able work with points and linear equations to:

  1. Define an equations for lines either from two known points, or one point and a gradient
  2. Calculate a new x,y point on an equation line that is a specific distance from another point on that equation line
  3. Drop a perpendicular onto an equation line from a point
  4. Perform variations of cosine-rule calculations on points and triangle sides defined as equations

I've roughed up some code for this a while ago based on high school "y = mx + c" concepts, but it's flawed (it fails with infinities when lines are vertical), and currently in Scala. Since I suspect I'm reinventing a wheel that's not my primary goal, I'd like to use someone else's work for this!

I've come across CGAL, and it seems very likely it's capable of all this and more, but I have two questions about it (given that it seems to take ages to get enough understanding of this kind of huge library to actually be able to answer simple questions!)

  1. It seems to assert some kind of mathematical perfection in it's calculations, but that's not important to me, and my system will be severely memory constrained. Does it use/offer memory efficient approximations?
  2. Is it possible (and hopefully easy) to separate out just a limited subset of features, or am I going to find the entire library (or even a very large subset) heading into my memory limited machine?

And, I suppose the inevitable follow up: are there more suitable libraries I'm unaware of?

embedded 2d linear-equation