LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
ray_2d.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa Akiyama
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_GEOM_RAY2D_H
33#define RCSC_GEOM_RAY2D_H
34
35#include <rcsc/geom/line_2d.h>
36#include <rcsc/geom/vector_2d.h>
37
38namespace rcsc {
39
44class Ray2D {
45private:
47 Vector2D M_origin;
49 AngleDeg M_direction;
50
51public:
56 : M_origin( 0.0, 0.0 ),
57 M_direction( 0.0 )
58 { }
59
66 const AngleDeg & direction )
67 : M_origin( origin ),
68 M_direction( direction )
69 { }
76 const Vector2D & dir_point )
77 : M_origin( origin ),
78 M_direction( ( dir_point - origin ).th() )
79 { }
80
85 const Vector2D & origin() const
86 {
87 return M_origin;
88 }
89
94 const AngleDeg & dir() const
95 {
96 return M_direction;
97 }
98
103 Line2D line() const
104 {
105 return Line2D( origin(), dir() );
106 }
107
114 bool inRightDir( const Vector2D & point,
115 const double thr = 10.0 ) const
116 {
117 return ( ( point - origin() ).th() - dir() ).abs() < thr;
118 }
119
126 Vector2D intersection( const Line2D & other ) const;
127
134 Vector2D intersection( const Ray2D & other ) const;
135
136};
137
138}
139
140#endif
degree wrapper class
Definition: angle_deg.h:45
2d straight line class
Definition: line_2d.h:47
2D ray line class
Definition: ray_2d.h:44
const Vector2D & origin() const
get origin point
Definition: ray_2d.h:85
Vector2D intersection(const Ray2D &other) const
get the intersection point with 'ray'
Ray2D(const Vector2D &origin, const Vector2D &dir_point)
constructor with origin and other point
Definition: ray_2d.h:75
const AngleDeg & dir() const
get the angle of this ray line
Definition: ray_2d.h:94
Line2D line() const
get line generated from this ray
Definition: ray_2d.h:103
Vector2D intersection(const Line2D &other) const
get the intersection point with 'line'
Ray2D()
defalut constructor. all values are set to 0.
Definition: ray_2d.h:55
bool inRightDir(const Vector2D &point, const double thr=10.0) const
check whether p is on the direction of this Ray
Definition: ray_2d.h:114
Ray2D(const Vector2D &origin, const AngleDeg &direction)
constructor with origin and direction
Definition: ray_2d.h:65
2D point vector class
Definition: vector_2d.h:46
2D straight line Header File.
2d vector class Header File.