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);}
85 if (o1 != o2 && o3 != o4)
89 if (o1 == 0 && other.
start.isBetweenPoints(
start,
end))
return true;
90 if (o2 == 0 && other.
end.isBetweenPoints(
start,
end))
return true;
91 if (o3 == 0 &&
start.isBetweenPoints( other.
start, other.
end))
return true;
92 if (o4 == 0 &&
end.isBetweenPoints( other.
start, other.
end))
return true;
111 return a.nearlyParallel(
b, factor);
123 if ( commonDenominator != 0.
f )
128 const f32 uA = numeratorA / commonDenominator;
173 if(
equals(commonDenominator, 0.
f))
177 if(!ignoreCoincidentLines &&
equals(numeratorA, 0.
f) &&
equals(numeratorB, 0.
f))
222 if (
end != maxp &&
end != minp)
226 if (l.
end != maxp && l.
end != minp)
228 out.
X = (T)(out.
X/2);
229 out.
Y = (T)(out.
Y/2);
240 const f32 uA = numeratorA / commonDenominator;
241 if (checkOnlySegments)
243 if(uA < 0.f || uA > 1.
f)
246 const f32 uB = numeratorB / commonDenominator;
247 if(uB < 0.f || uB > 1.
f)
306 f64 d =
v.getLength();
312 if ( checkOnlySegments )
334 const f32 d = (
f32)
v.getLength();
338 const f32 t =
v.dotProduct(
c);
340 if ( checkOnlySegments )
343 if (
t > d)
return end;
line2d(T xa, T ya, T xb, T yb)
Constructor for line between the two points.
line2d< T > operator-(const vector2d< T > &point) const
vector2d< T > start
Start point of the line.
float f32
32 bit floating point variable.
vector2d< T > getClosestPoint(const vector2d< T > &point, bool checkOnlySegments=true) const
Get the closest point on this line to a point.
T Y
Y coordinate of vector.
bool lineIntersectSegment(const line2d< T > &segment, vector2d< T > &out) const
Everything in the Irrlicht Engine can be found in this namespace.
line2d< s32 > line2di
Typedef for an integer line.
f64 getAngleWith(const vector2d< T > &b) const
Calculates the angle between this vector and another one in degree.
bool incidentSegments(const line2d< T > &other) const
bool operator!=(const line2d< T > &other) const
double f64
64 bit floating point variable.
void setLine(const line2d< T > &line)
Set this line to new line given as parameter.
vector2d< T > getUnitVector() const
Get unit vector of the line.
bool isPointBetweenStartAndEnd(const vector2d< T > &point) const
Check if the given point is between start and end of the line.
vector2d< T > getVector() const
Get the vector of the line.
line2d< T > & operator-=(const vector2d< T > &point)
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
signed int s32
32 bit signed variable.
T getPointOrientation(const vector2d< T > &point) const
Tells us if the given point lies to the left, right, or on the line.
void setLine(const vector2d< T > &nstart, const vector2d< T > &nend)
Set this line to new line going through the two points.
T getLength() const
Get length of line.
line2d< T > operator+(const vector2d< T > &point) const
bool nearlyParallel(const line2d< T > &line, const T factor=relativeErrorFactor< T >()) const
line2d< f32 > line2df
Typedef for an f32 line.
bool isPointOnLine(const vector2d< T > &point) const
Check if the given point is a member of the line.
line2d(const vector2d< T > &start, const vector2d< T > &end)
Constructor for line between the two points given as vectors.
bool operator==(const line2d< T > &other) const
line2d()
Default constructor for line going from (0,0) to (1,1).
GLboolean GLboolean GLboolean b
vector2d< T > fastLinesIntersection(const line2d< T > &l) const
2d vector template class with lots of operators and methods.
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.
f64 getAngleWith(const line2d< T > &l) const
Get angle between this line and given line.
line2d< T > & operator+=(const vector2d< T > &point)
bool intersectWith(const line2d< T > &l, vector2d< T > &out, bool checkOnlySegments=true, bool ignoreCoincidentLines=false) const
Tests if this line intersects with another line.
line2d(const line2d< T > &other)
Copy constructor.
GLboolean GLboolean GLboolean GLboolean a
vector2d< T > end
End point of the line.
vector2d< T > getMiddle() const
Get middle of the line.
2D line between two points with intersection methods.
T getLengthSQ() const
Get squared length of the line.
bool intersectAsSegments(const line2d< T > &other) const
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.
T X
X coordinate of vector.