Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SFPoint3f.cpp

Go to the documentation of this file.
00001 #include "SFPoint3f.h"
00002 #include "SFString.h"
00003 
00004 #include <sstream>
00005 
00006 using namespace X3DTK;
00007 using namespace std;
00008 
00009 SFPoint3f::SFPoint3f() {}
00010 
00011 SFPoint3f::SFPoint3f(float x, float y, float z)
00012 {
00013   this->x = x;
00014   this->y = y;
00015   this->z = z;
00016 }
00017 
00018 SFPoint3f::SFPoint3f(const SFPoint3f &p)
00019 {
00020   x = p.x;
00021   y = p.y;
00022   z = p.z;
00023 }
00024 
00025 SFPoint3f &SFPoint3f::operator= (SFPoint3f v)
00026 {
00027   x = v.x;
00028   y = v.y;
00029   z = v.z;
00030   return *this;
00031 }
00032 
00033 SFPoint3f::SFPoint3f(const SFString &s)
00034 {
00035   istringstream iss(s, istringstream::in);
00036   iss >> x >> y >> z;
00037 }
00038 
00039 SFPoint3f::SFPoint3f(const SFVec3f &V)
00040 {
00041   x = V.x;
00042   y = V.y;
00043   z = V.z;
00044 }
00045 
00046 // operations on points
00047 //overloading of the operators +, -, *
00048 
00049 SFPoint3f X3DTK::operator+ (const SFPoint3f &v1, const SFVec3f &v2)
00050 {
00051   SFPoint3f res;
00052   res.x = v1.x + v2.x;
00053   res.y = v1.y + v2.y;
00054   res.z = v1.z + v2.z;
00055   return res;
00056 }
00057 
00058 SFPoint3f X3DTK::operator- (const SFPoint3f &v1, const SFVec3f &v2)
00059 {
00060   SFPoint3f res;
00061   res.x = v1.x - v2.x;
00062   res.y = v1.y - v2.y;
00063   res.z = v1.z - v2.z;
00064   return res;
00065 }
00066 
00067 SFVec3f X3DTK::operator- (const SFPoint3f &v1, const SFPoint3f &v2)
00068 {
00069   SFVec3f res;
00070   res.x = v1.x - v2.x;
00071   res.y = v1.y - v2.y;
00072   res.z = v1.z - v2.z;
00073   return res;
00074 }
00075 
00076 SFPoint3f X3DTK::operator* (const float a, const SFPoint3f &v)
00077 {
00078   SFPoint3f res;
00079   res.x = a * v.x;
00080   res.y = a * v.y;
00081   res.z = a * v.z;
00082   return res;
00083 }
00084 
00085 float X3DTK::distance(const SFPoint3f &A, const SFPoint3f &B)
00086 {
00087   return (A - B).norm();
00088 }
00089 

Generated on Wed May 14 10:03:11 2003 for X3DToolKit by doxygen1.3