R2Vector operator/(const R2Vector& vector, double a) { assert(a != 0); return R2Vector(vector.X() / a, vector.Y() / a); }
R2Vector operator*(const R2Vector& vector1, const R2Vector& vector2) { // Entry by entry multiply (not dot or cross product) return R2Vector(vector1.v[0] * vector2.v[0], vector1.v[1] * vector2.v[1]); }
R2Vector operator/(const R2Vector& vector1, const R2Vector& vector2) { assert(vector2.v[0] != 0); assert(vector2.v[1] != 0); return R2Vector(vector1.v[0] / vector2.v[0], vector1.v[1] / vector2.v[1]); }
R2Line:: R2Line(const R2Point& point1, const R2Point& point2) : vector(point2 - point1) { this->vector.Normalize(); normal = R2Vector(this->vector.Y(), -(this->vector.X())); c = -(normal.X()*point1.X() + normal.Y()*point1.Y()); }
R2Line:: R2Line(const R2Point& point, const R2Vector& vector, RNBoolean normalized) : vector(vector) { if (!normalized) this->vector.Normalize(); normal = R2Vector(this->vector.Y(), -(this->vector.X())); c = -(normal.X()*point.X() + normal.Y()*point.Y()); }
void R2Line:: Align(const R2Vector& vector, RNBoolean normalized) { // Set vector of line this->vector = vector; if (!normalized) this->vector.Normalize(); this->normal = R2Vector(this->vector.Y(), -this->vector.X()); }
R2Vector operator*(const R3Matrix& a, const R2Vector& v) { // Multiply matrix by vector RNCoord x = a.m[0][0] * v.X() + a.m[0][1] * v.Y(); RNCoord y = a.m[1][0] * v.X() + a.m[1][1] * v.Y(); return R2Vector(x, y); }
R2Line:: R2Line(RNCoord x1, RNCoord y1, RNCoord x2, RNCoord y2) : vector(x2-x1, y2-y1) { this->vector.Normalize(); normal = R2Vector(this->vector.Y(), -(this->vector.X())); c = -(normal.X()*x1 + normal.Y()*y1); }
void R2Line:: Mirror(const R2Line& line) { // Mirror line over another line R2Point p = (normal * -c).Point(); p.Mirror(line); vector.Mirror(line); normal = R2Vector(vector.Y(), -(vector.X())); c = -(normal.X()*p.X() + normal.Y()*p.Y()); }
void R2Line:: InverseTransform (const R2Transformation& transformation) { // Inverse Transform line vector.InverseTransform(transformation); vector.Normalize(); normal = R2Vector(vector.Y(), -vector.X()); R2Point p(Point()); p.InverseTransform(transformation); Reposition(p); }
void GWindow::drawLineRel(double dx, double dy) { drawLineRel(R2Vector(dx, dy)); }
R2Vector operator-(const R2Point& point1, const R2Point& point2) { return R2Vector(point1.v[0] - point2.v[0], point1.v[1] - point2.v[1]); }
R2Vector operator*(const R2Vector& vector, double a) { return R2Vector(vector.X() * a, vector.Y() * a); }
R2Vector operator-(const R2Vector& vector1, const R2Vector& vector2) { return R2Vector(vector1.v[0] - vector2.v[0], vector1.v[1] - vector2.v[1]); }
R2Vector operator-(const R2Vector& vector) { return R2Vector(-vector.X(), -vector.Y()); }
R2Halfspace:: R2Halfspace(const R2Point& point, const R2Vector& normal) : line(point, R2Vector(-normal.Y(), normal.X())) { }
/* Source file for the GAPS diad class */ /* Include files */ #include "R2Shapes/R2Shapes.h" /* Public variables */ const R2Diad R2xy_diad(R2Vector(1.0, 0.0), R2Vector(0.0, 1.0)); /* Public functions */ int R2InitDiad() { /* Return success */ return TRUE; } void R2StopDiad() { }
R2Vector R2Point:: Vector(void) const { // Return vector to point from origin return R2Vector(v[0], v[1]); }
void GWindow::moveRel(double dx, double dy) { moveRel(R2Vector(dx, dy)); }