Line feature requests


#1

It would be nice if there was a function that returned the equation of the line.

Something like:

void Line::getLineEquation(float& m, float& b)
{
  m = (getStartY() - getEndY()) / (getStartX() - getEndX());
  b = getStartY() - m * getStartX();
}

Also be nice if there was a function, if you gave it an x would return the y on the line.

float Line::yForX(float x)
{
  m = (getStartY() - getEndY()) / (getStartX() - getEndX());
  b = getStartY() - m * getStartX();

  return m * x + b;
}

I guess it would also need to test for vertical lines so it didn’t blow up.