Skip to content
Snippets Groups Projects
Commit f8e10e99 authored by Tom Fischer's avatar Tom Fischer
Browse files

[GeoLib] Check if two 3d vectors are parallel.

parent 4009c9c8
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,24 @@ Orientation getOrientation(const GeoLib::Point* p0, const GeoLib::Point* p1,
return getOrientation((*p0)[0], (*p0)[1], (*p1)[0], (*p1)[1], (*p2)[0], (*p2)[1]);
}
bool checkParallelism(double const*const v, double const*const w)
{
// normalise
const double len_v(sqrt(MathLib::scpr<double,3>(v,v)));
const double len_w(sqrt(MathLib::scpr<double,3>(w,w)));
double coeff[3] = {
(v[0]*len_w) / (w[0]*len_v),
(v[1]*len_w) / (w[1]*len_v),
(v[2]*len_w) / (w[2]*len_v)
};
if (abs(coeff[0]-coeff[1]) < std::numeric_limits<double>::epsilon() &&
abs(coeff[0]-coeff[2]) < std::numeric_limits<double>::epsilon())
return true;
return false;
}
bool lineSegmentIntersect(const GeoLib::Point& a, const GeoLib::Point& b, const GeoLib::Point& c,
const GeoLib::Point& d, GeoLib::Point& s)
{
......
......@@ -114,6 +114,14 @@ bool lineSegmentsIntersect (const GeoLib::Polyline* ply,
std::size_t &idx1,
GeoLib::Point& intersection_pnt);
/**
* Check if the two vectors \f$v, w \in R^3\f$ are in parallel
* @param v double array of length 3
* @param w double array of length 3
* @return true if the vectors are in parallel, else false
*/
bool checkParallelism(double const*const v, double const*const w);
/**
* A line segment is given by its two end-points. The function checks,
* if the two line segments (ab) and (cd) intersects. Up to now only
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment