Point:点是三维空间中的一个位置。
Vector:矢量通常表示三维空间中的一个方向(以及相应的大小)。
向量归一化:向量归一化的过程包括改变向量,使其长度变为1,但方向不变。
法线:用于描述几何对象在该表面上一点的表面方向。从技术上讲,在点P上垂直于表面的法线,可以看作是垂直于点P上与表面相切的平面的向量。
线性变换:如果在变换时保留了直线,那么我们说线性变换(与矩阵相乘是线性变换)。
Transformation(转换):
The translation operator is nothing more than a linear transformation of the original point (which can be viewed as an input position point). Applied to a vector (which, remember, is a direction), translation has no meaning. This is because where the vector begins (that is, where it is centered) is not important; regardless of position, all “arrows” of the same length, pointing in the same direction, are equivalent. Instead, we very commonly use another linear transformation on vectors: rotation.
The subscripted letter T stands for “transformed”.
在我们的c++代码中,我们不会区分点、向量和法线;我们用一个Vec3类来表示这三个类(一个类模板,这样我们可以根据需要创建浮点型、整型或双型版本)。一些开发人员喜欢将它们区分开来。这显然限制了犯错的可能性。我们仍然需要小心地调用一些特定的函数,这取决于我们处理的Vec3是表示点、向量还是法向量。
template<typename T>
class Vec3
{
public:
// 3 most basic ways of initializing a vector
Vec3() : x(T(0)), y(T(0)), z(T(0)) {}
Vec3(const T &xx) : x(xx), y(xx), z(xx) {}
Vec3(T xx, T yy, T zz) : x(xx), y(yy), z(zz) {}
T x, y, z;
};
typedef Vec3<float> Vec3f;
Vec3<float> a;
Vec3f b;