#include "marLine.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- marLine::marLine(){ this->a = 1; this->b = 1; this->c = 0; } // ---------------------------------------------------------------------------- marLine::marLine(double x1, double y1, double x2, double y2){ this->a = y2 - y1; //REVISAR SIGNO this->b = (x1 - x2); this->c = (y1 - y2) * x1 + (x2 - x1)*y1; } // ---------------------------------------------------------------------------- marLine::marLine(double a, double b){ this->a = a; this->b = b; this->c = 0; } // ---------------------------------------------------------------------------- void marLine::getNormal(double *a, double *b){ *a = (this->b); *b = this->a; } // ---------------------------------------------------------------------------- void marLine::getIntersect(double a, double b, double c, double *x, double *y){ if (this->a == a){ *x = -1; *y = -1; return; } if (this->b == b){ *x = -1; *y = -1; return; } *x = (c*this->b - this->c*b) / (this->a*b - a*this->b); if (this->b == 0){ *y = -c/b; } else if (b == 0){ *y = -this->c/this->b; } else { *y = (-this->a*(*x) - this->c) / this->b; } if (*x < 0 || *y < 0){ *x = -1; *y = -1; } } // ---------------------------------------------------------------------------- double marLine::getA(){ return a; } // ---------------------------------------------------------------------------- double marLine::getB(){ return b; } // ---------------------------------------------------------------------------- double marLine::getC(){ return c; } // ---------------------------------------------------------------------------- marLine::~marLine(){ }