5 #ifndef __IRR_LINE_2D_H_INCLUDED__
6 #define __IRR_LINE_2D_H_INCLUDED__
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.
bool isPointOnLine(const vector2d< T > &point) const
Check if the given point is a member of the line.
f64 getAngleWith(const line2d< T > &l) const
Get angle between this line and given line.
bool operator==(const line2d< T > &other) const
vector2d< T > getMiddle() const
Get middle of the line.
line2d(const line2d< T > &other)
Copy constructor.
void setLine(const vector2d< T > &nstart, const vector2d< T > &nend)
Set this line to new line going through the two points.
vector2d< T > end
End point of the line.
line2d(const vector2d< T > &start, const vector2d< T > &end)
Constructor for line between the two points given as vectors.
line2d< T > & operator-=(const vector2d< T > &point)
bool isPointBetweenStartAndEnd(const vector2d< T > &point) const
Check if the given point is between start and end of the line.
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.
line2d< T > & operator+=(const vector2d< T > &point)
T getLength() const
Get length of line.
line2d()
Default constructor for line going from (0,0) to (1,1).
T getPointOrientation(const vector2d< T > &point) const
Tells us if the given point lies to the left, right, or on the line.
line2d< T > operator-(const vector2d< T > &point) const
bool operator!=(const line2d< T > &other) const
bool intersectWith(const line2d< T > &l, vector2d< T > &out, bool checkOnlySegments=true) const
Tests if this line intersects with another line.
T getLengthSQ() const
Get squared length of the line.
line2d< T > operator+(const vector2d< T > &point) const
vector2d< T > getUnitVector() const
Get unit vector of the line.
vector2d< T > start
Start point of the line.
vector2d< T > getVector() const
Get the vector of the line.
vector2d< T > getClosestPoint(const vector2d< T > &point, bool checkOnlySegments=true) const
Get the closest point on this line to a point.
void setLine(const line2d< T > &line)
Set this line to new line given as parameter.
line2d(T xa, T ya, T xb, T yb)
Constructor for line between the two points.
2d vector template class with lots of operators and methods.
f64 getAngleWith(const vector2d< T > &b) const
Calculates the angle between this vector and another one in degree.
T getLength() const
Gets the length of the vector.
T X
X coordinate of vector.
T Y
Y coordinate of vector.
T dotProduct(const vector2d< T > &other) const
Get the dot product of this vector with another.
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.
line2d< f32 > line2df
Typedef for an f32 line.
line2d< s32 > line2di
Typedef for an integer line.
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
Everything in the Irrlicht Engine can be found in this namespace.
float f32
32 bit floating point variable.
double f64
64 bit floating point variable.