Files
envi-code/SourceCode/Code2026/tg_shs/inc/subgeo/TGVector2D.h
T
2026-09-28 15:28:50 +08:00

80 lines
2.3 KiB
C++

//-------------------------------------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TGVector2D 类
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: TGVector2D 声明
// = Maintainers:
//
//-------------------------------------------------------------------------------------------------------+
#ifndef _TGVECTOR2D_H_
#define _TGVECTOR2D_H_
#ifndef _TGPOINT_H_
#include "TGPoint.h"
#endif
class GEOAPI TGVector2D : public TGPoint
{
public:
//construct
TGVector2D(double x = 0,double y = 0,double z = 0);
TGVector2D(double*p);
TGVector2D(float*p);
TGVector2D(const TGPoint& pt);
TGVector2D(const TGPoint& fromPt,const TGPoint& toPt);
~TGVector2D();
void Polar(double angle);
double Length() const;
bool IsValid() const;
bool IsNullVector() const;
bool IsNormalized() const;
bool Normalize();
void SetVector(double x,double y);
void SetLength(double len);
void Reverse();
TGVector2D operator -() const;
TGVector2D operator +(const TGPoint& vt) const;
TGVector2D operator -(const TGPoint& vt) const;
TGVector2D operator *(double rate) const;
TGVector2D operator /(double rate) const;
void operator += (const TGPoint& vt);
void operator -= (const TGPoint& vt);
void operator *= (double rate);
void operator /= (double rate);
double operator & (const TGPoint& vt) const;
double operator * (const TGPoint& vt) const;
bool operator == (const TGPoint& pt) const;
bool operator != (const TGPoint& pt) const;
bool IsParallel(const TGPoint& vt,bool bNormalized = false) const;
bool IsVectorLeft(const TGPoint& vt,bool bNormalized = false) const;
bool IsVectorRight(const TGPoint& vt,bool bNormalized = false) const;
bool IsVert(const TGPoint& vt,bool bNormalized = false) const;
//夹角小于90度
bool IsSameDirection(const TGPoint& vt,bool bNormalized = false) const;
//夹角大于90度
bool IsReverseDirection(const TGPoint& vt,bool bNormalized = false) const;
//from vt to this [0,PI*2)
double GetAngleWith(const TGPoint& vt,bool bNormalized = false) const;
//from X axis to this,[0,PI*2)
double GetAngle() const;
void GetLVertVector(TGPoint& vt) const;
void GetRVertVector(TGPoint& vt) const;
};
#endif