Minor Code Style Update + Documentation Spelling Fix

This commit is contained in:
2019-12-19 12:03:21 +01:00
parent 9db5304edc
commit 2da9e15d36
9 changed files with 51 additions and 60 deletions

View File

@@ -11,7 +11,7 @@
class IntelliColorPicker{
public:
/*!
* \brief IntelliColorPicker construktor, setting 2 preset colors, be careful, theese color may change in production.
* \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production.
*/
IntelliColorPicker();

View File

@@ -5,7 +5,7 @@
std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> polyPoints){
//helper for managing the triangle vertices and their state
// helper for managing the triangle vertices and their state
struct TriangleHelper{
QPoint vertex;
float interiorAngle;
@@ -13,7 +13,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
bool isTip;
};
//calculates the inner angle of 'point'
// calculates the inner angle of 'point'
auto calculateInner = [](QPoint& point, QPoint& prev, QPoint& post){
QPoint AP(point.x()-prev.x(), point.y()-prev.y());
QPoint BP(point.x()-post.x(), point.y()-post.y());
@@ -23,7 +23,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
return acos(topSclar/absolute);
};
//gets the first element of vec for which element.isTip == true holds
// gets the first element of vec for which element.isTip == true holds
auto getTip= [](const std::vector<TriangleHelper>& vec){
for(auto element:vec){
if(element.isTip){
@@ -33,17 +33,17 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
return vec[0];
};
//get the vertex Index bevor index in relation to the container length
// get the vertex Index bevor index in relation to the container length
auto getPrev = [](int index, int length){
return (index-1)>0?(index-1):(length-1);
};
//get the vertex Index after index in relation to the container lenght
// get the vertex Index after index in relation to the container lenght
auto getPost = [](int index, int length){
return (index+1)%length;
};
//return if the vertex is a tip
// return if the vertex is a tip
auto isTip = [](float angle){
return angle<180.f;
};
@@ -51,7 +51,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
std::vector<TriangleHelper> Vertices;
std::vector<Triangle> Triangles;
//set up all vertices and calculate intirior angle
// set up all vertices and calculate intirior angle
for(int i=0; i<static_cast<int>(polyPoints.size()); i++){
TriangleHelper helper;
int prev = getPrev(i, static_cast<int>(polyPoints.size()));
@@ -67,48 +67,47 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
Vertices.push_back(helper);
}
//search triangles based on the intirior angles of each vertey
// search triangles based on the intirior angles of each vertey
while(Triangles.size() != polyPoints.size()-2){
Triangle tri;
TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.index, static_cast<int>(Vertices.size()));
int post = getPost(smallest.index, static_cast<int>(Vertices.size()));
//set triangle and push it
// set triangle and push it
tri.A = Vertices[static_cast<size_t>(prev)].vertex;
tri.B = Vertices[static_cast<size_t>(smallest.index)].vertex;
tri.C = Vertices[static_cast<size_t>(post)].vertex;
Triangles.push_back(tri);
//update Vertice array
// update Vertice array
Vertices.erase(Vertices.begin()+smallest.index);
for(size_t i=static_cast<size_t>(smallest.index); i<Vertices.size(); i++){
Vertices[i].index-=1;
}
//update post und prev index
// update post und prev index
post = post-1;
prev = prev<smallest.index?prev:(prev-1);
//calcultae neighboors of prev and post to calculate new interior angles
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));
int postOfPrev = getPost(prev, static_cast<int>(Vertices.size()));
int prevOfPost = getPrev(post, static_cast<int>(Vertices.size()));
int postOfPost = getPost(post, static_cast<int>(Vertices.size()));
//update vertices with interior angles
//updtae prev
// update vertices with interior angles
// updtae prev
Vertices[static_cast<size_t>(prev)].interiorAngle = calculateInner(Vertices[static_cast<size_t>(prev)].vertex,
Vertices[static_cast<size_t>(prevOfPrev)].vertex,
Vertices[static_cast<size_t>(postOfPrev)].vertex);
Vertices[static_cast<size_t>(prev)].isTip = isTip(Vertices[static_cast<size_t>(prev)].interiorAngle);
//update post
// update post
Vertices[static_cast<size_t>(post)].interiorAngle = calculateInner(Vertices[static_cast<size_t>(post)].vertex,
Vertices[static_cast<size_t>(prevOfPost)].vertex,
Vertices[static_cast<size_t>(postOfPost)].vertex);
Vertices[static_cast<size_t>(post)].isTip = isTip(Vertices[static_cast<size_t>(post)].interiorAngle);
}
return Triangles;
}

View File

@@ -11,7 +11,6 @@ struct Triangle{
QPoint A,B,C;
};
namespace IntelliHelper {
/*!
@@ -59,7 +58,6 @@ namespace IntelliHelper {
* \return Returns true if the point lies in the üpolygon, otherwise false.
*/
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
}
#endif