5#ifndef __IRR_LINE_2D_H_INCLUDED__
6#define __IRR_LINE_2D_H_INCLUDED__
33 line2d<T>& operator+=(
const vector2d<T>& point) {
start += point;
end += point;
return *
this; }
36 line2d<T>& operator-=(
const vector2d<T>& point) {
start -= point;
end -= point;
return *
this; }
38 bool operator==(
const line2d<T>& other)
const
39 {
return (
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
40 bool operator!=(
const line2d<T>& other)
const
41 {
return !(
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
45 void setLine(
const T& xa,
const T& ya,
const T& xb,
const T& yb){
start.set(xa, ya);
end.set(xb, yb);}
90 if(
equals(commonDenominator, 0.f))
139 if (
end != maxp &&
end != minp)
143 if (l.
end != maxp && l.
end != minp)
145 out.X = (T)(out.X/2);
146 out.Y = (T)(out.Y/2);
157 const f32 uA = numeratorA / commonDenominator;
158 if(checkOnlySegments && (uA < 0.f || uA > 1.f) )
161 const f32 uB = numeratorB / commonDenominator;
162 if(checkOnlySegments && (uB < 0.f || uB > 1.f))
226 if ( checkOnlySegments )
254 if ( checkOnlySegments )
256 if (t < 0)
return start;
257 if (t > d)
return end;
2D line between two points with intersection methods.
Definition line2d.h:19
bool isPointOnLine(const vector2d< T > &point) const
Check if the given point is a member of the line.
Definition line2d.h:200
f64 getAngleWith(const line2d< T > &l) const
Get angle between this line and given line.
Definition line2d.h:182
line2d(const line2d< T > &other)
Copy constructor.
Definition line2d.h:28
void setLine(const vector2d< T > &nstart, const vector2d< T > &nend)
Set this line to new line going through the two points.
Definition line2d.h:47
vector2d< T > getClosestPoint(const vector2d< T > &point, bool checkOnlySegments=true) const
Get the closest point on this line to a point.
Definition line2d.h:216
vector2d< f32 > end
Definition line2d.h:239
line2d(const vector2d< T > &start, const vector2d< T > &end)
Constructor for line between the two points given as vectors.
Definition line2d.h:26
vector2d< T > getMiddle() const
Get middle of the line.
Definition line2d.h:61
bool isPointBetweenStartAndEnd(const vector2d< T > &point) const
Check if the given point is between start and end of the line.
Definition line2d.h:208
void setLine(const T &xa, const T &ya, const T &xb, const T &yb)
Set this line to new line going through the two points.
Definition line2d.h:45
vector2d< T > getUnitVector() const
Get unit vector of the line.
Definition line2d.h:173
T getLength() const
Get length of line.
Definition line2d.h:53
line2d()
Default constructor for line going from (0,0) to (1,1).
Definition line2d.h:22
T getPointOrientation(const vector2d< T > &point) const
Tells us if the given point lies to the left, right, or on the line.
Definition line2d.h:192
bool intersectWith(const line2d< T > &l, vector2d< T > &out, bool checkOnlySegments=true) const
Tests if this line intersects with another line.
Definition line2d.h:77
T getLengthSQ() const
Get squared length of the line.
Definition line2d.h:57
vector2d< f32 > start
Definition line2d.h:237
vector2d< T > getVector() const
Get the vector of the line.
Definition line2d.h:68
void setLine(const line2d< T > &line)
Set this line to new line given as parameter.
Definition line2d.h:49
line2d(T xa, T ya, T xb, T yb)
Constructor for line between the two points.
Definition line2d.h:24
2d vector template class with lots of operators and methods.
Definition vector2d.h:22
f64 getAngleWith(const vector2d< T > &b) const
Calculates the angle between this vector and another one in degree.
Definition vector2d.h:238
T getLength() const
Gets the length of the vector.
Definition vector2d.h:114
T X
X coordinate of vector.
Definition vector2d.h:316
T Y
Y coordinate of vector.
Definition vector2d.h:319
T dotProduct(const vector2d< T > &other) const
Get the dot product of this vector with another.
Definition vector2d.h:124
bool isBetweenPoints(const vector2d< T > &begin, const vector2d< T > &end) const
Returns if this vector interpreted as a point is on a line between two other points.
Definition vector2d.h:259
Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
Definition aabbox3d.h:15
line2d< f32 > line2df
Typedef for an f32 line.
Definition line2d.h:266
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
line2d< s32 > line2di
Typedef for an integer line.
Definition line2d.h:268
bool equals(const f64 a, const f64 b, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals b, taking possible rounding errors into account
Definition irrMath.h:185
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
double f64
64 bit floating point variable.
Definition irrTypes.h:108