📄 mgcvector2.h
字号:
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement. The various license agreements may be found at
// the Magic Software web site. This file is subject to the license
//
// FREE SOURCE CODE
// http://www.magic-software.com/License/free.pdf
#ifndef MGCVECTOR2_H
#define MGCVECTOR2_H
#include "MgcMath.h"
class MgcVector2
{
public:
// construction
MgcVector2 ();
MgcVector2 (MgcReal fX, MgcReal fY);
MgcVector2 (MgcReal afCoordinate[2]);
MgcVector2 (const MgcVector2& rkVector);
// member access (allows V.x or V[0], V.y or V[1])
MgcReal x, y;
MgcReal& operator[] (int i) const;
operator MgcReal* ();
// assignment and comparison
MgcVector2& operator= (const MgcVector2& rkVector);
bool operator== (const MgcVector2& rkVector) const;
bool operator!= (const MgcVector2& rkVector) const;
// arithmetic operations
MgcVector2 operator+ (const MgcVector2& rkVector) const;
MgcVector2 operator- (const MgcVector2& rkVector) const;
MgcVector2 operator* (MgcReal fScalar) const;
MgcVector2 operator/ (MgcReal fScalar) const;
MgcVector2 operator- () const;
friend MgcVector2 operator* (MgcReal fScalar, const MgcVector2& rkVector);
// arithmetic updates
MgcVector2& operator+= (const MgcVector2& rkVector);
MgcVector2& operator-= (const MgcVector2& rkVector);
MgcVector2& operator*= (MgcReal fScalar);
MgcVector2& operator/= (MgcReal fScalar);
// vector operations
MgcReal Length () const;
MgcReal SquaredLength () const;
MgcReal Dot (const MgcVector2& rkVector) const;
MgcReal Unitize (MgcReal fTolerance = 1e-06);
MgcVector2 Cross () const;
MgcVector2 UnitCross () const;
// Gram-Schmidt orthonormalization.
static void Orthonormalize (MgcVector2 akVector[2]);
// special points
static const MgcVector2 ZERO;
static const MgcVector2 UNIT_X;
static const MgcVector2 UNIT_Y;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -