#pragma once

#include "ray.h"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Line3D ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Line : public Ray
{
public:
	Scalar length;

	Line()	{}
	Line(const Ray &ray, Scalar length) : Ray(ray), length(length)	{}
	Line(const Point3D &start, const UnitVector &direction, Scalar length) : Ray(start,direction), length(length)	{}

	void FindEnd(Point3D *result)
	{
		Check(this);
		Check_Pointer(result);
		Ray::Project(length, result);
	}
		
	//
	// Assignment operators
	//
	Line& operator=(const Vector3D &vector);
	Line& operator=(const Point3D &point);
	//
	// Ray intersection functions
	//
	Scalar DistanceTo(const Plane &plane, Scalar *product) const;
	Scalar DistanceTo(const Sphere &sphere, Scalar *penetration) const;
};
