📄 hmg.h
字号:
//
// hmg.h
//
// $Id: hmg.h,v 1.1.1.1 2001/02/28 00:28:35 cstolte Exp $
//
#ifndef SGL_HMG_H
#define SGL_HMG_H
#include <sgl/defs.h>
#include <iostream>
#include <math.h>
class Point2;
class Vector2;
class Point3;
class Vector3;
class Homogeneous2 {
public:
double u, v, d;
Homogeneous2() { }
Homogeneous2(double, double, double = 1);
Homogeneous2(const Point2 &);
Homogeneous2(const Vector2 &);
operator Point2() const;
operator Vector2() const;
Homogeneous2 operator-() const;
Homogeneous2 operator+(const Homogeneous2 &) const;
Homogeneous2 &operator+=(const Homogeneous2 &);
Homogeneous2 operator-(const Homogeneous2 &) const;
Homogeneous2 &operator-=(const Homogeneous2 &);
Homogeneous2 operator*(double) const;
Homogeneous2 &operator*=(double);
Homogeneous2 operator/(double) const;
Homogeneous2 &operator/=(double);
bool operator==(const Homogeneous2 &) const;
bool operator!=(const Homogeneous2 &) const;
Homogeneous2 normalize() const;
Homogeneous2 hat() const { return normalize(); }
double length() const { return sqrt(length_squared()); }
double length_squared() const;
void print(std::ostream& os) const { os << u << ", " << v << ", " << d; }
};
class Homogeneous3 {
public:
double x, y, z, d;
Homogeneous3() { }
Homogeneous3(double, double, double, double = 1);
Homogeneous3(const Point3 &);
Homogeneous3(const Vector3 &);
operator Point3() const;
operator Vector3() const;
Homogeneous3 operator-() const;
Homogeneous3 operator+(const Homogeneous3 &) const;
Homogeneous3 &operator+=(const Homogeneous3 &);
Homogeneous3 operator-(const Homogeneous3 &) const;
Homogeneous3 &operator-=(const Homogeneous3 &);
Homogeneous3 operator*(double) const;
Homogeneous3 &operator*=(double);
Homogeneous3 operator/(double) const;
Homogeneous3 &operator/=(double);
bool operator==(const Homogeneous3 &) const;
bool operator!=(const Homogeneous3 &) const;
Homogeneous3 normalize() const;
Homogeneous3 hat() const { return normalize(); }
double length() const { return sqrt(length_squared()); }
double length_squared() const;
void print(std::ostream& os) const { os << x << ", " << y <<
", " << z << ", " << d; }
};
#endif /* SGL_HMG_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -