summaryrefslogtreecommitdiff
path: root/Runtime/Geometry/Ray2D.h
blob: 7adff8eefc60f41576b70a7ce30b42bb235610f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef RAY2D_H
#define RAY2D_H

#include "Runtime/Math/Vector2.h"


// --------------------------------------------------------------------------


class Ray2D
{
#if UNITY_FLASH //flash needs to be able to set these fields
public:
#endif
	Vector2f	m_Origin;
	Vector2f	m_Direction; // Direction is always normalized
	
public:
	Ray2D () {}
	Ray2D (const Vector2f& origin, const Vector2f& direction) { m_Origin = origin; SetDirection (direction); }
		
	const Vector2f& GetOrigin ()const { return m_Origin; }
	void SetOrigin (const Vector2f& origin)	{ m_Origin = origin; }

	const Vector2f& GetDirection () const { return m_Direction; }
	void SetDirection (const Vector2f& direction) { AssertIf (!IsNormalized (direction)); m_Direction = direction; }
	void SetApproxDirection (const Vector2f& direction) { m_Direction = NormalizeFast (direction); }

	Vector2f GetPoint (const float scale) const { return m_Origin + (scale * m_Direction); }
};

#endif