ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki

line2d.h

Go to the documentation of this file.
```00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022
00023 #ifndef MATH_LINE2D_H
00024 #define MATH_LINE2D_H
00025
00026 #include "math/vector2d.h"
00027
00028 namespace Math {
00029
00030 class Line2d {
00031 public:
00032     Line2d();
00033     Line2d(const Vector2d &direction, const Vector2d &point);
00034
00035     Line2d getPerpendicular(const Vector2d &point = Vector2d()) const;
00036     Vector2d getDirection() const;
00037     float getDistanceTo(const Vector2d &point, Vector2d *intersection) const;
00038
00039     bool intersectsLine(const Line2d &line, Vector2d *pos) const;
00040     bool containsPoint(const Vector2d &point) const;
00041
00042     float getYatX(float x) const;
00043
00044     friend Common::Debug &operator<<(Common::Debug &dbg, const Line2d &line);
00045
00046 private:
00047     float _a, _b, _c;
00048
00049 };
00050
00051 class Segment2d {
00052 public:
00053     Segment2d();
00054     Segment2d(const Vector2d &begin, const Vector2d &end);
00055     Segment2d(const Segment2d &other);
00056
00057     Vector2d begin() const;
00058     Vector2d end() const;
00059     Vector2d middle() const;
00060     Line2d getLine() const;
00061     Line2d getPerpendicular(const Vector2d &point = Vector2d()) const;
00062
00063     bool containsPoint(const Vector2d &point) const;
00064
00065     bool intersectsLine(const Line2d &line, Vector2d *pos);
00066     bool intersectsSegment(const Segment2d &line, Vector2d *pos);
00067
00068     Segment2d &operator=(const Segment2d &other);
00069
00070 private:
00071     Math::Vector2d _begin, _end;
00072
00073 };
00074
00075 }
00076
00077 #endif
00078
00079
```

Generated on Sat May 30 2020 05:01:08 for ResidualVM by  1.7.1