#pragma once #include "math.h" class Vect3usi { public: Vect3usi(); Vect3usi(unsigned short z, unsigned short y, unsigned short x); ~Vect3usi(void); // ---------------------------------------------------------------------------------------- // INLINED functions // ---------------------------------------------------------------------------------------- // Operators void operator = (Vect3usi &rhs); bool operator == (Vect3usi &rhs); bool operator != (Vect3usi &rhs); // Additional functions bool equal_to(unsigned short z, unsigned short y, unsigned short x); bool is_within_bounds( Vect3usi &lower, Vect3usi &upper ); void to_zyx(unsigned short &z, unsigned short &y, unsigned short &x); void from_zyx(unsigned short z, unsigned short y, unsigned short x); void add_char(char z, char y, char x); void add(unsigned short z, unsigned short y, unsigned short x); void add(Vect3usi &this_vect); int get_mag(); // ---------------------------------------------------------------------------------------- // Additional operations // ---------------------------------------------------------------------------------------- unsigned int get_dist_2_to(Vect3usi &dst); unsigned short get_dist_man_to(Vect3usi &dst); void get_unit_direction_to(Vect3usi &dst, char &rdz, char &rdy, char &rdx); // ---------------------------------------------------------------------------------------- // Public variables // ---------------------------------------------------------------------------------------- public: unsigned short x, y, z; }; // ======================================================================================== // INLINED METHOD IMPLEMENTATIONS // // ---------------------------------------------------------------------------------------- // Overloaded operators // ---------------------------------------------------------------------------------------- inline void Vect3usi::operator = (Vect3usi &rhs) { this->x = rhs.x; this->y = rhs.y; this->z = rhs.z; }; inline bool Vect3usi::operator == (Vect3usi &rhs) { return ( ((this->x==rhs.x) && (this->y==rhs.y) && (this->z==rhs.z)) ? (true) : (false) ); }; inline bool Vect3usi::operator != (Vect3usi &rhs) { return ( ((this->x==rhs.x) && (this->y==rhs.y) && (this->z==rhs.z)) ? (false) : (true) ); }; // ---------------------------------------------------------------------------------------- // Additional functions // ---------------------------------------------------------------------------------------- inline bool Vect3usi::equal_to(unsigned short z, unsigned short y, unsigned short x) { return ( ((z==this->z) && (y==this->y) && (x==this->x)) ? (true) : (false) ); }; inline bool Vect3usi::is_within_bounds( Vect3usi &lower, Vect3usi &upper ) { return ( ((this->x >= lower.x) && (this->x <= upper.x) && (this->y >= lower.y) && (this->y <= upper.y) && (this->z >= lower.z) && (this->z <= upper.z)) ? (true) : (false) ) ; }; inline void Vect3usi::to_zyx(unsigned short &z, unsigned short &y, unsigned short &x) { z = this->z; y = this->y; x = this->x; }; inline void Vect3usi::from_zyx(unsigned short z, unsigned short y, unsigned short x) { this->z = z; this->y = y; this->x = x; }; inline void Vect3usi::add_char(char z, char y, char x) { this->z = this->z + z; this->y = this->y + y; this->x = this->x + x; }; inline void Vect3usi::add(unsigned short z, unsigned short y, unsigned short x) { this->z = this->z + z; this->y = this->y + y; this->x = this->x + x; }; inline void Vect3usi::add(Vect3usi &this_vect) { this->z = this->z + this_vect.z; this->y = this->y + this_vect.y; this->x = this->x + this_vect.x; }; inline int Vect3usi::get_mag() { return (this->z*this->z + this->y*this->y + this->x*this->x); }