Point3D

# Point3D - P if(this ==&rhs return*this r x = rhs.x y = rhs.y z = rhs.z x return*this distance distance between two points double

This preview shows pages 1–2. Sign up to view the full content.

// this file contains the definition of the class Point3D / #include <math.h> #include "Point3D.h" # // --------------------------------------------- default constructor / Point3D::Point3D() :x(0), y(0), z(0) {} { // --------------------------------------------- constructor / Point3D::Point3D(const double a) :x(a), y(a), z(a) {} { // --------------------------------------------- constructor / Point3D::Point3D(const double a, const double b, const double c) :x(a), y(b), z(c) {} { // --------------------------------------------- copy constructor / :x(p.x), y(p.y), z(p.z) {} { // --------------------------------------------- destructor / Point3D::~Point3D() {} { // --------------------------------------------- assignment operator / Point3D&

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P if (this == &rhs) return (*this); r x = rhs.x; y = rhs.y; z = rhs.z; x return (*this); } // --------------------------------------------- distance // distance between two points / double Point3D::distance(const Point3D& p) const { return (sqrt( (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) + (z - p.z) * (z - p.z) )); } // non-member function / // --------------------------------------------- operator* // multiplication by a matrix on the left / Point3D P operator* (const Matrix& mat, const Point3D& p) { return (Point3D(mat.m[0][0] * p.x + mat.m[0][1] * p.y + mat.m[0][2] * p.z + mat.m[0][3], mat.m[1][0] * p.x + mat.m[1][1] * p.y + mat.m[1][2] * p.z + mat.m[1][3], mat.m[2][0] * p.x + mat.m[2][1] * p.y + mat.m[2][2] * p.z + mat.m[2][3])); }...
View Full Document

## This note was uploaded on 02/19/2010 for the course CS 390 taught by Professor Hu during the Spring '10 term at Westminster UT.

### Page1 / 2

Point3D - P if(this ==&rhs return*this r x = rhs.x y = rhs.y z = rhs.z x return*this distance distance between two points double

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online