// // point2d.cc // // A point in 2d space // // Copyright (C) J. Belson 1998.11.30 // #include "point2d.h" /** * Constructor */ point2d::point2d(float xx, float yy, float d) { x = xx; y = yy; depth = d; } /** * Return coordinates of this point */ void point2d::get(float *xx, float *yy, float *d) const { *xx = x; *yy = y; *d = depth; } /** * Set coordinates of this point */ void point2d::set(float xx, float yy, float d) { x = xx; y = yy; depth = d; } /** * Set colour of this point */ void point2d::set_colour(uint8 red, uint8 green, uint8 blue) { col.r = red/255.0; col.g = green/255.0; col.b = blue/255.0; } /** * Get colour of this point */ fcolour point2d::get_colour(void) const { return col; } /** * Apply scaling factor to this point */ point2d point2d::operator*(double f) { point2d p(x*f, y*f, depth); return p; } /** * Subtract vector from this point */ vector2d point2d::operator-(const point2d& p) const { vector2d v(x - p.x, y - p.y); return v; } /** * Write specified point coordinates to a stream. * @param str stream to write to * @param p point to operate on */ std::ostream& operator<<(std::ostream& str, const point2d& p) { //str << std::setprecision(4); str << "(" << p.x << ", " << p.y << ", " << p.depth << ")"; return str; }