Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
6d0a3532
Commit
6d0a3532
authored
Dec 06, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unnecessary parts.
parent
e76a151e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
175 deletions
+4
-175
ttl_util.h
include/ttl/ttl_util.h
+4
-175
No files found.
include/ttl/ttl_util.h
View file @
6d0a3532
...
...
@@ -56,7 +56,7 @@
/** \brief Utilities
*
*
* This name space contains utility functions for TTL.\n
*
* Point and vector algebra such as scalar product and cross product
...
...
@@ -73,10 +73,10 @@
* which is the z-component of the actual cross product
* (the x and y components are both zero).
*
* \see
* \see
* ttl and \ref api
*
* \author
* \author
* Øyvind Hjelle, oyvindhj@ifi.uio.no
*/
...
...
@@ -118,7 +118,7 @@ namespace ttl_util {
return
dx1
*
dy2
-
dy1
*
dx2
;
}
//------------------------------------------------------------------------------------------------
/** Returns a positive value if the 2D nodes/points \e pa, \e pb, and
* \e pc occur in counterclockwise order; a negative value if they occur
...
...
@@ -138,177 +138,6 @@ namespace ttl_util {
return
acx
*
bcy
-
acy
*
bcx
;
}
//------------------------------------------------------------------------------------------------
/* Scalar product between 2D vectors represented as darts.
*
* \par Requires:
* - real_type DartType::x()
* - real_type DartType::y()
*/
/*
template <class TTLtraits, class DartType>
typename TTLtraits::real_type scalarProduct2d(const DartType& d1, const DartType& d2) {
DartType d10 = d1;
d10.alpha0();
DartType d20 = d2;
d20.alpha0();
return scalarProduct2d(d10.x() - d1.x(), d10.y() - d1.y(), d20.x() - d2.x(), d20.y() - d2.y());
}
*/
//------------------------------------------------------------------------------------------------
/* Scalar product between 2D vectors.
* The first vector is represented by the given dart, and the second vector has
* direction from the node of the given dart - and to the given point.
*
* \par Requires:
* - real_type DartType::x(), real_type DartType::y()
* - real_type PointType2d::x(), real_type PointType2d::y()
*/
/*
template <class TTLtraits>
typename TTLtraits::real_type scalarProduct2d(const typename TTLtraits::DartType& d,
const typename TTLtraits::PointType2d& p) {
typename TTLtraits::DartType d0 = d;
d0.alpha0();
return scalarProduct2d(d0.x() - d.x(), d0.y() - d.y(), p.x() - d.x(), p.y() - d.y());
}
*/
//------------------------------------------------------------------------------------------------
/* Cross product between 2D vectors represented as darts.
*
* \par Requires:
* - real_type DartType::x(), real_type DartType::y()
*/
/*
template <class TTLtraits>
typename TTLtraits::real_type crossProduct2d(const typename TTLtraits::DartType& d1,
const typename TTLtraits::DartType& d2) {
TTLtraits::DartType d10 = d1;
d10.alpha0();
TTLtraits::DartType d20 = d2;
d20.alpha0();
return crossProduct2d(d10.x() - d1.x(), d10.y() - d1.y(), d20.x() - d2.x(), d20.y() - d2.y());
}
*/
//------------------------------------------------------------------------------------------------
/* Cross product between 2D vectors.
* The first vector is represented by the given dart, and the second vector has
* direction from the node associated with given dart - and to the given point.
*
* \par Requires:
* - real_type DartType::x()
* - real_type DartType::y()
*/
/*
template <class TTLtraits>
typename TTLtraits::real_type crossProduct2d(const typename TTLtraits::DartType& d,
const typename TTLtraits::PointType2d& p) {
TTLtraits::DartType d0 = d;
d0.alpha0();
return crossProduct2d(d0.x() - d.x(), d0.y() - d.y(), p.x() - d.x(), p.y() - d.y());
}
*/
// Geometric predicates; see more robust schemes by Jonathan Richard Shewchuk at
// http://www.cs.cmu.edu/~quake/robust.html
//------------------------------------------------------------------------------------------------
/* Return a positive value if the 2d nodes/points \e d, \e d.alpha0(), and
* \e p occur in counterclockwise order; a negative value if they occur
* in clockwise order; and zero if they are collinear. The
* result is also a rough approximation of twice the signed
* area of the triangle defined by the three points.
*
* \par Requires:
* - DartType::x(), DartType::y(),
* - PointType2d::x(), PointType2d::y()
*/
/*
template <class TTLtraits, class DartType, class PointType2d>
typename TTLtraits::real_type orient2dfast(const DartType& n1, const DartType& n2,
const PointType2d& p) {
return ((n2.x()-n1.x())*(p.y()-n1.y()) - (p.x()-n1.x())*(n2.y()-n1.y()));
}
*/
//@} // End of Computational geometry
//------------------------------------------------------------------------------------------------
// ---------------------------- Utilities Involving Points Group --------------------------------
//------------------------------------------------------------------------------------------------
/** @name Utilities involving points */
//@{
//------------------------------------------------------------------------------------------------
/** Creates random data on the unit square.
*
* \param noPoints
* Number of random points to be generated
*
* \param seed
* Initial value for pseudorandom number generator
*
* \require
* - Constructor \c PointType::PointType(double x, double y).\n
* For example, one can use \c pair<double, double>.
*
* \note
* - To deduce template argument for PointType the function must be
* called with the syntax: \c createRandomData<MyPoint>(...) where \c MyPoint
* is the actual point type.
*/
template
<
class
PointType
>
std
::
vector
<
PointType
*>*
createRandomData
(
int
noPoints
,
int
seed
=
1
)
{
#ifdef _MSC_VER
srand
(
seed
);
#else
srand48
((
long
int
)
seed
);
#endif
double
x
,
y
;
std
::
vector
<
PointType
*>*
points
=
new
std
::
vector
<
PointType
*>
(
noPoints
);
typename
std
::
vector
<
PointType
*>::
iterator
it
;
for
(
it
=
points
->
begin
();
it
!=
points
->
end
();
++
it
)
{
#ifdef _MSC_VER
int
random
=
rand
();
x
=
((
double
)
random
/
(
double
)
RAND_MAX
);
random
=
rand
();
y
=
((
double
)
random
/
(
double
)
RAND_MAX
);
*
it
=
new
PointType
(
x
,
y
);
#else
double
random
=
drand48
();
x
=
random
;
random
=
drand48
();
y
=
random
;
*
it
=
new
PointType
(
x
,
y
);
#endif
}
return
points
;
}
//@} // End of Utilities involving points
};
// End of ttl_util namespace scope
#endif // _TTL_UTIL_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment