5#ifndef DCPP_LINE_2D_HPP_INCLUDED
6#define DCPP_LINE_2D_HPP_INCLUDED
8#include <duckcpp/core/engine/dcpp_types.hpp>
9#include <duckcpp/core/engine/vector2d.hpp>
38 line2d<T>& operator+=(
const vector2d<T>& point) {
start += point;
end += point;
return *
this; }
40 line2d<T> operator-(
const vector2d<T>& point)
const {
return line2d<T>(
start - point,
end - point); }
41 line2d<T>& operator-=(
const vector2d<T>& point) {
start -= point;
end -= point;
return *
this; }
43 bool operator==(
const line2d<T>& other)
const
44 {
return (
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
45 bool operator!=(
const line2d<T>& other)
const
46 {
return !(
start==other.start &&
end==other.end) || (
end==other.start &&
start==other.end);}
97 if (
o4 == 0 &&
end.isBetweenPoints(
other.start,
other.end))
return true;
116 return a.nearlyParallel( b,
factor);
131 (
l.end.Y -
l.start.Y)*(
start.X -
l.start.X));
173 (
l.end.Y -
l.start.Y)*(
start.X -
l.start.X));
187 else if(
l.end ==
end ||
l.start ==
end)
209 else if ((
l.start.X>
start.X &&
l.start.X>
l.end.X &&
l.start.X>
end.X) || (
l.start.Y>
start.Y &&
l.start.Y>
l.end.Y &&
l.start.Y>
end.Y))
217 else if (
maxp !=
l.start && ((
l.start.X<
start.X &&
l.start.X<
l.end.X &&
l.start.X<
end.X) || (
l.start.Y<
start.Y &&
l.start.Y<
l.end.Y &&
l.start.Y<
end.Y)))
349 if (
t >
d)
return end;
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
2D line between two points with intersection methods.
Definition line2d.hpp:26
bool lineIntersectSegment(const line2d< T > &segment, vector2d< T > &out) const
Definition line2d.hpp:146
line2d(T xa, T ya, T xb, T yb)
Constructor for line between the two points.
Definition line2d.hpp:31
T getLength() const
Get length of line.
Definition line2d.hpp:58
bool incidentSegments(const line2d< T > &other) const
Definition line2d.hpp:103
vector2d< T > getClosestPoint(const vector2d< T > &point, bool checkOnlySegments=true) const
Get the closest point on this line to a point.
Definition line2d.hpp:308
vector2d< T > getMiddle() const
Get middle of the line.
Definition line2d.hpp:66
void setLine(const line2d< T > &line)
Set this line to new line given as parameter.
Definition line2d.hpp:54
vector2d< T > getVector() const
Get the vector of the line.
Definition line2d.hpp:73
bool nearlyParallel(const line2d< T > &line, const T factor=relativeErrorFactor< T >()) const
Definition line2d.hpp:111
T getPointOrientation(const vector2d< T > &point) const
Tells us if the given point lies to the left, right, or on the line.
Definition line2d.hpp:283
T getLengthSQ() const
Get squared length of the line.
Definition line2d.hpp:62
bool isPointOnLine(const vector2d< T > &point) const
Check if the given point is a member of the line.
Definition line2d.hpp:291
vector2d< T > start
Start point of the line.
Definition line2d.hpp:329
dcpp::float64_kt getAngleWith(const line2d< T > &l) const
Get angle between this line and given line.
Definition line2d.hpp:273
bool intersectWith(const line2d< T > &l, vector2d< T > &out, bool checkOnlySegments=true, bool ignoreCoincidentLines=false) const
Tests if this line intersects with another line.
Definition line2d.hpp:165
void setLine(const vector2d< T > &nstart, const vector2d< T > &nend)
Set this line to new line going through the two points.
Definition line2d.hpp:52
vector2d< T > getUnitVector() const
Get unit vector of the line.
Definition line2d.hpp:264
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.hpp:50
vector2d< T > end
End point of the line.
Definition line2d.hpp:331
vector2d< T > fastLinesIntersection(const line2d< T > &l) const
Definition line2d.hpp:123
line2d()
Default constructor for line going from (0,0) to (1,1).
Definition line2d.hpp:29
bool intersectAsSegments(const line2d< T > &other) const
Definition line2d.hpp:77
bool isPointBetweenStartAndEnd(const vector2d< T > &point) const
Check if the given point is between start and end of the line.
Definition line2d.hpp:299
line2d(const vector2d< T > &start, const vector2d< T > &end)
Constructor for line between the two points given as vectors.
Definition line2d.hpp:33
2d vector template class with lots of operators and methods.
Definition vector2d.hpp:22
T getLength() const
Gets the length of the vector.
Definition vector2d.hpp:125
T dotProduct(const vector2d< T > &other) const
Get the dot product of this vector with another.
Definition vector2d.hpp:135
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition irrMath.hpp:243
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
double float64_kt
64 bit floating point variable.
Definition irrTypes.hpp:112
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72