//////// File: Vector.C ////////// #include #include "Vector.h" Vector::Vector(float a, float b) { x = a; y = b; } float Vector::inner(Vector a) { return(x * a.x + y * a.y); } void Vector::display() { cout << "(" << x << ", " << y << ")"; } Vector Vector::operator-(Vector a) { Vector tmp; tmp.x = x - a.x; tmp.y = y - a.y; return(tmp); } inline float ABS(float x) { return (x > 0 ? x : -x); } // test if the host is parallel to a (pointing in the same direction) int Vector::is_parallel(Vector a) { return( nonzero() && a.nonzero() && x*a.x >= 0.0 && y*a.y >= 0.0 && ABS(x*a.y-y*a.x) < 0.00000001 ); }