📄 transform2.h
字号:
//
// transform2.h
//
// $Id: transform2.h,v 1.1.1.1 2001/02/28 00:28:39 cstolte Exp $
//
#ifndef SGL_TRANSFORM2_H
#define SGL_TRANSFORM2_H
#include <sgl/defs.h>
#include <sgl/vecmath2.h>
#include <sgl/hmg.h>
class Transform2;
///
/// Matrix2
///
class Matrix2 {
public:
Matrix2() { }
Matrix2(double a00, double a01,
double a10, double a11);
friend std::ostream &operator<<(std::ostream &, const Matrix2 &);
Matrix2 operator*(const Matrix2 &) const;
Matrix2 &operator*=(const Matrix2 &);
Matrix2 operator+(const Matrix2 &) const;
Matrix2 &operator+=(const Matrix2 &);
Matrix2 operator-(const Matrix2 &) const;
Matrix2 &operator-=(const Matrix2 &);
Matrix2 &identity();
Matrix2 &zero();
Matrix2 &rotate(double theta);
Matrix2 &scale(double su, double sv);
Matrix2 &transpose();
Matrix2 &invert();
Matrix2 &shearu(double a);
Matrix2 &shearv(double a);
Matrix2 inverse() const { Matrix2 ret(*this); return ret.invert(); }
double determinant() const;
bool operator==(const Matrix2 &) const;
bool operator!=(const Matrix2 &) const;
Point2 apply(const Point2 &)const;
Vector2 apply(const Vector2 &) const;
Normal2 apply(const Normal2 &, const Matrix2 * = 0) const;
static const Matrix2 unit;
//CO protected:
friend class Transform2;
Normal2 row(int) const;
Vector2 column(int) const;
double T[2][2];
};
extern Matrix2 identityM2();
extern Matrix2 rotate(double);
extern Matrix2 scale(double, double);
extern Matrix2 shearu(double);
extern Matrix2 shearv(double);
//
// Transform2
//
class Transform2 : public Matrix2 {
public:
Transform2() { }
Transform2(const Matrix2 &);
Transform2(const Matrix2 &, const Vector2 &);
friend std::ostream &operator<<(std::ostream &, const Transform2 &);
friend Transform2 operator*(const Matrix2 &, const Transform2 &);
Transform2 operator*(const Transform2 &) const;
Transform2 operator*(const Matrix2 &) const;
Transform2 &operator*=(const Transform2 &);
Transform2 &operator*=(const Matrix2 &);
Transform2 &identity();
Transform2 &translate(double tu, double tv);
Transform2 &rotate(double angle);
Transform2 &scale(double su, double sv);
Transform2 &invert();
Transform2 inverse() const { Transform2 ret(*this); return ret.invert(); }
Point2 apply(const Point2 &) const;
Vector2 apply(const Vector2 &) const;
Normal2 apply(const Normal2 &, const Transform2 * = 0) const;
bool operator==(const Transform2 &) const;
bool operator!=(const Transform2 &) const;
static const Transform2 unit;
//CO private:
Vector2 translation;
};
extern Transform2 translate(double, double);
#endif // SGL_TRANSFORM2_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -