ray.h

来自「一个纹理地形渲染器」· C头文件 代码 · 共 43 行

H
43
字号
// Ray class

#pragma once

#include "Vector.h"


namespace Mathematics
{
    /// %Ray from origin point in specified direction

    class Ray
    {
    public:

        /// default constructor.
        /// does nothing for speed.

        Ray() {};

		/// construct a ray from given origin and direction.
		/// note: the ray direction must be unit length!

        Ray(const Vector &origin, const Vector &direction)
        {
			assert(direction.normalized());

            this->origin = origin;
            this->direction = direction;
        }

        /// calculate point along ray.

        Vector point(float t) const
        {
            return origin + direction * t;
        }

        Vector origin;          ///< origin of ray
        Vector direction;       ///< direction of ray (always unit length)
    };
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?