|
//############################################################################
// Author: Sharjith Nair
// Email: sharjith_ssn@hotmail.com
// Program: OpenGL, C++, MFC StereoLithography Data File Viewer Application
// Important Notice:
// This Idea and the Application is Copyright(c) Sharjith Nair 2002, 2003.
// You can freely use it as long as you credit me for it.
// No guarantee/warranty is given on this app and I will not be responsible
// for any damage to you, your property or any other person from using it.
// USE IT ON YOUR OWN RISK.
// Thankyou
// Sharjith Nair.
//#############################################################################
// Vector3d.h: interface for the CVector3d class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_VECTOR3D_H__DD3ABF1E_D4ED_4D0B_A32B_C5AD8CAFA517__INCLUDED_)
#define AFX_VECTOR3D_H__DD3ABF1E_D4ED_4D0B_A32B_C5AD8CAFA517__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Geometry.h"
class CPoint3D;
class CMatrix33;
class COneAxis;
class CPlane;
class CVector3D : public CGeometry
{
public:
CVector3D();
CVector3D(double x, double y, double z);
CVector3D(const CPoint3D&);
CVector3D(const CVector3D&, const CVector3D&);
CVector3D(const CPoint3D&, const CPoint3D&);
~CVector3D();
void SetX(double x){itsX = x;} //Set The X Component Value
void SetY(double y){itsY = y;} //Set The Y Component Value
void SetZ(double z){itsZ = z;} //Set The Z Component Value
void SetParam(double x, double y, double z){itsX = x; itsY = y;itsZ = z;} //Set The X Y and Z Values
double GetX() const {return itsX;}// Returns The X Component
double GetY() const {return itsY;}// Returns The Y Component
double GetZ() const {return itsZ;}// Returns The Z Component
double Dot(const CVector3D &V1) const;//Calculate Dot Product
double DotCross(const CVector3D &V1, const CVector3D &V2);//Calculate Scalar Triple Product
void Cross(const CVector3D &V1);//Calculate Cross Product Of' this' And Other
CVector3D Crossed(const CVector3D &V1) const;//Return The Cross Product Vector
void CrossCross(const CVector3D &V1, const CVector3D &V2);//Calculate The Vector Triple Product
CVector3D CrossCrossed(const CVector3D &V1, const CVector3D &V2);//Return Vector Triple Product
void Reverse();//Reverse The Direction Of 'this'
CVector3D Reversed();//Return The Reversed Vector Of 'this'
CVector3D operator + (const CVector3D &V1);//Return Addition Of 'this' And Other
void operator += (const CVector3D &V1);//Add Other To 'this'
CVector3D operator - (const CVector3D &V1);//Return Subtraction Of 'this' And Other
void operator -= (const CVector3D &V1);//Subtract Other From 'this'
CVector3D operator * (const double &scalar);//Scalar Multiple With Other Vector
CVector3D operator * (const CMatrix33& M);//Multiply With Matrix
void operator *= (const double &scalar);//Multiply 'this' With Other
void operator *= (const CMatrix33 &M);//Multiply 'this With Matrix
CVector3D operator / (const double &scalar);//Scalar Division
void operator /= (const double &scalar);//Divide 'this' By Scalar
CVector3D operator ^ (const CVector3D &V1);//Return The Cross Product
void operator ^= (const CVector3D &V1);//Calculate Cross Product Of' this' And Other
double Magnitude() const;// Calculate 'this' Vector's Magnitude
double SqrMagnitude() const;// Calculate 'this' Vector's Square Magnitude
double CrossMagnitude(const CVector3D &V);// Calculate 'this' Vector's Cross Magnitude
double CrossSqrMagnitude(const CVector3D &V1);// Calculate 'this' Vector's Cross Square Magnitude
double Modulus();// Return Modulus
CVector3D Unit();//Return Normalized Vector Of 'this'
CPoint3D Point();//Return Component Triplet As Point
double Angle(const CVector3D&) const;//Angle Bet'n 'this' And Other
double Angle(const CVector3D&, const CVector3D&) const;//Angle Bet'n 'this' And Other WRT Direction
bool IsNull() const;//Check For Null Vector
bool IsParallel(const CVector3D&) const;//Check If Parallel To Other
bool IsOpposite(const CVector3D&) const;//Check If Opposite Direction To Other
bool IsNormal(const CVector3D&) const;//Check If Normal To Other
bool operator == (const CVector3D& V) const;//Check Equality
operator CPoint3D();//Convertion Cast To Point;
void Print() const;//Print Values Of Components
void Normalize();//Normalize 'this' Vector
virtual void Translate(const COneAxis&, const double&);
virtual void Translate(double dx, double dy, double dz);
virtual void Translate(const CVector3D&);
virtual void Translate(const CPoint3D&, const CPoint3D&);
virtual void Rotate(const COneAxis&, double);
virtual void Scale(const CPoint3D&, double);
virtual void Mirror(const CPoint3D&);
virtual void Mirror(const COneAxis&);
virtual void Mirror(const CPlane&);
static CVector3D Origin();
private:
double itsX;
double itsY;
double itsZ;
};
#endif // !defined(AFX_VECTOR3D_H__DD3ABF1E_D4ED_4D0B_A32B_C5AD8CAFA517__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.