double Line::calcY(Point p) { if (doubleEquals(b,0)) { return p.y; } else { return (-c - a*p.x)/b; } }
void BytecodeTranslatorVisitor::visitDoubleLiteralNode(DoubleLiteralNode* node) { onVisitNode(node); const double value = node->literal(); if (doubleEquals(value, -1.0)) EMIT(BC_DLOADM1); else if (doubleEquals(value, 0.0)) EMIT(BC_DLOAD0); else if (doubleEquals(value, 1.0)) EMIT(BC_DLOAD1); else { EMIT(BC_DLOAD); EMIT_DOUBLE(value); } pushType(VT_DOUBLE); }
//http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=geometry2 Point Line::getIntersect(Line that) { double det = this->a*that.b - that.a*this->b; if (doubleEquals(det,0)) { return Point(0,0); // Should use isIntersect to find this is invalid. } else { return Point((this->b*that.c - that.b*this->c)/det, (that.a*this->c-this->a*that.c)/det); } }
bool Line::containsPoint(Point p) { return doubleEquals(this->a*p.x + this->b*p.y, -this->c); }
bool Line::isIntersect(Line that) { return !doubleEquals(this->a*that.b - that.a *this->b,0); }
double Line::getAcuteAngleToYAxis() { if (doubleEquals(b,0)) { return 0; } return atan(-this->a/this->b); }