Skip to content
Snippets Groups Projects
Commit 2a298cf6 authored by Andrei Herdt's avatar Andrei Herdt Committed by Olivier Stasse
Browse files

Add structure to handle 2-dimensional convex hulls

- Add type convex_hull_t
- Add method resize(int&)
- Add method reset(void)
- Add method set(double*,double*)
- Add method rotate(double&)
parent 4d440440
No related branches found
No related tags found
No related merge requests found
......@@ -127,4 +127,55 @@ namespace PatternGeneratorJRL
reset();
}
void
convex_hull_t::rotate(const double & angle)
{
double c_a = cos(angle);
double s_a = sin(angle);
for( int j=0;j<X.size();j++ )
{
X[j] = ( X[j]*c_a - Y[j]*s_a );
Y[j] = ( X[j]*s_a + Y[j]*c_a );
}
}
convex_hull_s::convex_hull_s(const int & size)
{
resize(size);
reset();
}
convex_hull_s::convex_hull_s()
{
}
void
convex_hull_t::reset()
{
X.clear();
Y.clear();
}
void
convex_hull_t::resize(const int & size)
{
X.resize(size);
Y.resize(size);
}
void
convex_hull_t::set(const double * arrayX, const double * arrayY)
{
for(int i=0;i<X.size();i++)
{
X[i] = arrayX[i];
Y[i] = arrayY[i];
}
}
}
......@@ -149,12 +149,43 @@ namespace PatternGeneratorJRL
/// \brief Linear constraints
struct linear_constraint_s
{
ublas::compressed_vector<double> A;
boost_ublas::compressed_vector<double> A;
double b;
};
typedef struct linear_constraint_s
linear_constraint_t;
/// \brief Set of 2-dimensional point
struct convex_hull_s
{
MAL_VECTOR(X,double);
MAL_VECTOR(Y,double);
/// \brief Rotate the points around the origin by angle
///
/// \param[in] angle
void rotate(const double & angle);
/// \brief Resize members to the desired number of points
///
/// \param[in] size
void resize(const int & size);
/// \brief Set the point values
///
/// \param[in] X
/// \param[in] Y
void set(const double * arrayX, const double * arrayY);
/// \brief Set all points to zero
void reset();
convex_hull_s(const int & size);
convex_hull_s();
};
typedef struct convex_hull_s convex_hull_t;
}
#endif /* _PATTERN_GENERATOR_INTERNAL_PRIVATE_H_ */
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