Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа №23 / Laba2 / cVector3D
.cpp#include "StdAfx.h"
#include ".\cVector3D.h"
#include <math.h>
cVector3D::cVector3D(void)
: X(0)
, Y(0)
, Z(0)
{
}
cVector3D::~cVector3D(void)
{
}
cVector3D cVector3D::MultVector(cVector3D& Vect)
{
float n_x;
float n_y;
float n_z;
n_x = this->Y*Vect.Z - this->Z*Vect.Y;
n_y = this->Z*Vect.X - this->X*Vect.Z;
n_z = this->X*Vect.Y - this->Y*Vect.X;
this->X = n_x;
this->Y = n_y;
this->Z = n_z;
return *this;
}
float cVector3D::MultScalar(cVector3D& Vect)
{
return (this->X*Vect.X + this->Y*Vect.Y + this->Z*Vect.Z);
}
cVector3D::cVector3D(float x, float y, float z)
: X(x)
, Y(y)
, Z(z)
{
}
cVector3D cVector3D::operator *(float Const)
{
this->X *= Const;
this->Y *= Const;
this->Z *= Const;
return *this;
}
cVector3D cVector3D::operator /(float Const)
{
if(Const != 0)
{
this->X /= Const;
this->Y /= Const;
this->Z /= Const;
}
else
{
this->X = 0;
this->Y = 0;
this->Z = 0;
}
return *this;
}
cVector3D cVector3D::operator +(cVector3D& Vect)
{
this->X += Vect.X;
this->Y += Vect.Y;
this->Z += Vect.Z;
return *this;
}
cVector3D cVector3D::operator -(cVector3D& Vect)
{
this->X -= Vect.X;
this->Y -= Vect.Y;
this->Z -= Vect.Z;
return *this;
}
float cVector3D::Norma(void)
{
return sqrt(X*X + Y*Y + Z*Z);
}
cVector3D cVector3D::operator =(cVector3D& Vect)
{
this->X = Vect.X;
this->Y = Vect.Y;
this->Z = Vect.Z;
return *this;
}