Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feliks Kiszkurno
ogs-feliks
Commits
8e8b5116
Commit
8e8b5116
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Moved AnalyticalGeometry.* from MathLib to GeoLib.
parent
40eb48d2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/AnalyticalGeometry.cpp
+12
-13
12 additions, 13 deletions
GeoLib/AnalyticalGeometry.cpp
GeoLib/AnalyticalGeometry.h
+24
-18
24 additions, 18 deletions
GeoLib/AnalyticalGeometry.h
with
36 additions
and
31 deletions
Math
Lib/AnalyticalGeometry.cpp
→
Geo
Lib/AnalyticalGeometry.cpp
+
12
−
13
View file @
8e8b5116
...
...
@@ -29,11 +29,10 @@
#include
"Triangle.h"
// MathLib
#include
"LinAlg/Dense/Matrix.h"
// for transformation matrix
#include
"LinAlg/Solvers/GaussAlgorithm.h"
#include
"MathTools.h"
namespace
Math
Lib
namespace
Geo
Lib
{
Orientation
getOrientation
(
const
double
&
p0_x
,
const
double
&
p0_y
,
const
double
&
p1_x
,
const
double
&
p1_y
,
const
double
&
p2_x
,
const
double
&
p2_y
)
...
...
@@ -59,7 +58,7 @@ Orientation getOrientation(const GeoLib::Point* p0, const GeoLib::Point* p1,
bool
lineSegmentIntersect
(
const
GeoLib
::
Point
&
a
,
const
GeoLib
::
Point
&
b
,
const
GeoLib
::
Point
&
c
,
const
GeoLib
::
Point
&
d
,
GeoLib
::
Point
&
s
)
{
Matrix
<
double
>
mat
(
2
,
2
);
MathLib
::
Matrix
<
double
>
mat
(
2
,
2
);
mat
(
0
,
0
)
=
b
[
0
]
-
a
[
0
];
mat
(
1
,
0
)
=
b
[
1
]
-
a
[
1
];
mat
(
0
,
1
)
=
c
[
0
]
-
d
[
0
];
...
...
@@ -88,7 +87,7 @@ bool lineSegmentIntersect(const GeoLib::Point& a, const GeoLib::Point& b, const
rhs
[
0
]
=
c
[
0
]
-
a
[
0
];
rhs
[
1
]
=
c
[
1
]
-
a
[
1
];
GaussAlgorithm
lu_solver
(
mat
);
MathLib
::
GaussAlgorithm
lu_solver
(
mat
);
lu_solver
.
execute
(
rhs
);
if
(
0
<=
rhs
[
0
]
&&
rhs
[
0
]
<=
1.0
&&
0
<=
rhs
[
1
]
&&
rhs
[
1
]
<=
1.0
)
{
s
[
0
]
=
a
[
0
]
+
rhs
[
0
]
*
(
b
[
0
]
-
a
[
0
]);
...
...
@@ -198,10 +197,10 @@ bool isPointInTriangle(GeoLib::Point const& p, GeoLib::Point const& a, GeoLib::P
}
// NewellPlane from book Real-Time Collision detection p. 494
void
getNewellPlane
(
const
std
::
vector
<
GeoLib
::
Point
*>&
pnts
,
Vector
&
plane_normal
,
double
&
d
)
void
getNewellPlane
(
const
std
::
vector
<
GeoLib
::
Point
*>&
pnts
,
MathLib
::
Vector
&
plane_normal
,
double
&
d
)
{
d
=
0
;
Vector
centroid
;
MathLib
::
Vector
centroid
;
size_t
n_pnts
(
pnts
.
size
());
for
(
size_t
i
(
n_pnts
-
1
),
j
(
0
);
j
<
n_pnts
;
i
=
j
,
j
++
)
{
plane_normal
[
0
]
+=
((
*
(
pnts
[
i
]))[
1
]
-
(
*
(
pnts
[
j
]))[
1
])
...
...
@@ -218,13 +217,13 @@ void getNewellPlane(const std::vector<GeoLib::Point*>& pnts, Vector &plane_norma
d
=
centroid
.
Dot
(
plane_normal
)
/
n_pnts
;
}
void
rotatePointsToXY
(
Vector
&
plane_normal
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
void
rotatePointsToXY
(
MathLib
::
Vector
&
plane_normal
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
{
double
small_value
(
sqrt
(
std
::
numeric_limits
<
double
>::
min
()));
if
(
fabs
(
plane_normal
[
0
])
<
small_value
&&
fabs
(
plane_normal
[
1
])
<
small_value
)
return
;
Matrix
<
double
>
rot_mat
(
3
,
3
);
MathLib
::
Matrix
<
double
>
rot_mat
(
3
,
3
);
computeRotationMatrixToXY
(
plane_normal
,
rot_mat
);
rotatePoints
(
rot_mat
,
pnts
);
...
...
@@ -235,7 +234,7 @@ void rotatePointsToXY(Vector &plane_normal, std::vector<GeoLib::Point*> &pnts)
delete
[]
tmp
;
}
void
rotatePointsToXZ
(
Vector
&
n
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
void
rotatePointsToXZ
(
MathLib
::
Vector
&
n
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
{
double
small_value
(
sqrt
(
std
::
numeric_limits
<
double
>::
min
()));
if
(
fabs
(
n
[
0
])
<
small_value
&&
fabs
(
n
[
1
])
<
small_value
)
...
...
@@ -249,7 +248,7 @@ void rotatePointsToXZ(Vector &n, std::vector<GeoLib::Point*> &pnts)
// 1 / sqrt (n_1^2 + n_2^2 + n_3^2)
const
double
h2
(
1.0
/
sqrt
(
h0
+
n
[
2
]
*
n
[
2
]));
Matrix
<
double
>
rot_mat
(
3
,
3
);
MathLib
::
Matrix
<
double
>
rot_mat
(
3
,
3
);
// calc rotation matrix
rot_mat
(
0
,
0
)
=
n
[
1
]
*
h1
;
rot_mat
(
0
,
1
)
=
-
n
[
0
]
*
h1
;
...
...
@@ -270,7 +269,7 @@ void rotatePointsToXZ(Vector &n, std::vector<GeoLib::Point*> &pnts)
delete
[]
tmp
;
}
void
computeRotationMatrixToXY
(
Vector
const
&
plane_normal
,
Matrix
<
double
>
&
rot_mat
)
void
computeRotationMatrixToXY
(
MathLib
::
Vector
const
&
plane_normal
,
MathLib
::
Matrix
<
double
>
&
rot_mat
)
{
// *** some frequently used terms ***
// sqrt (v_1^2 + v_2^2)
...
...
@@ -293,7 +292,7 @@ void computeRotationMatrixToXY(Vector const& plane_normal, Matrix<double> & rot_
rot_mat
(
2
,
2
)
=
plane_normal
[
2
]
*
h2
;
}
void
rotatePoints
(
Matrix
<
double
>
const
&
rot_mat
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
void
rotatePoints
(
MathLib
::
Matrix
<
double
>
const
&
rot_mat
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
)
{
double
*
tmp
(
NULL
);
const
std
::
size_t
n_pnts
(
pnts
.
size
());
...
...
@@ -304,4 +303,4 @@ void rotatePoints(Matrix<double> const& rot_mat, std::vector<GeoLib::Point*> &pn
delete
[]
tmp
;
}
}
}
// end namespace
Math
Lib
}
// end namespace
Geo
Lib
This diff is collapsed.
Click to expand it.
Math
Lib/AnalyticalGeometry.h
→
Geo
Lib/AnalyticalGeometry.h
+
24
−
18
View file @
8e8b5116
...
...
@@ -15,22 +15,20 @@
#ifndef ANALYTICAL_GEOMETRY_H_
#define ANALYTICAL_GEOMETRY_H_
// MathLib
#include
"Vector3.h"
#include
"LinAlg/Dense/Matrix.h"
// GeoLib
#include
"Triangle.h"
namespace
Geo
Lib
{
class
Polyline
;
}
// Math
Lib
#include
"LinAlg/Dense/Matrix.h"
#include
"Vector3.h"
namespace
MathLib
{
namespace
GeoLib
{
class
Polyline
;
enum
Orientation
{
CW
=
1
,
CCW
=
2
,
COLLINEAR
=
3
enum
Orientation
{
CW
=
1
,
CCW
=
2
,
COLLINEAR
=
3
};
/**
...
...
@@ -45,7 +43,9 @@ Orientation getOrientation (const double& p0_x, const double& p0_y,
/**
* wrapper for getOrientation ()
*/
Orientation
getOrientation
(
const
GeoLib
::
Point
*
p0
,
const
GeoLib
::
Point
*
p1
,
const
GeoLib
::
Point
*
p2
);
Orientation
getOrientation
(
const
GeoLib
::
Point
*
p0
,
const
GeoLib
::
Point
*
p1
,
const
GeoLib
::
Point
*
p2
);
/**
* compute a supporting plane (represented by plane_normal and the value d) for the polygon
...
...
@@ -55,7 +55,9 @@ Orientation getOrientation (const GeoLib::Point* p0, const GeoLib::Point* p1, co
* @param plane_normal the normal of the plane the polygon is located in
* @param d parameter from the plane equation
*/
void
getNewellPlane
(
const
std
::
vector
<
GeoLib
::
Point
*>&
pnts
,
MathLib
::
Vector
&
plane_normal
,
double
&
d
);
void
getNewellPlane
(
const
std
::
vector
<
GeoLib
::
Point
*>&
pnts
,
MathLib
::
Vector
&
plane_normal
,
double
&
d
);
/**
* The vector plane_normal should be the surface normal of the plane surface described
...
...
@@ -84,14 +86,15 @@ void rotatePointsToXZ(MathLib::Vector &plane_normal, std::vector<GeoLib::Point*>
* @param vec the (3d) vector that is rotated parallel to the \f$z\f$ axis
* @param rot_mat 3x3 rotation matrix
*/
void
computeRotationMatrixToXY
(
Vector
const
&
plane_normal
,
Matrix
<
double
>
&
rot_mat
);
void
computeRotationMatrixToXY
(
MathLib
::
Vector
const
&
plane_normal
,
MathLib
::
Matrix
<
double
>
&
rot_mat
);
/**
* rotate points according to the rotation matrix
* @param rot_mat 3x3 dimensional rotation matrix
* @param pnts vector of points
*/
void
rotatePoints
(
Matrix
<
double
>
const
&
rot_mat
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
);
void
rotatePoints
(
MathLib
::
Matrix
<
double
>
const
&
rot_mat
,
std
::
vector
<
GeoLib
::
Point
*>
&
pnts
);
bool
isPointInTriangle
(
const
GeoLib
::
Point
*
p
,
const
GeoLib
::
Point
*
a
,
const
GeoLib
::
Point
*
b
,
const
GeoLib
::
Point
*
c
);
...
...
@@ -108,7 +111,10 @@ bool isPointInTriangle(GeoLib::Point const& p,
* @param intersection_pnt the intersection point if the line segments intersect
* @return true, if the polyline contains intersections
*/
bool
lineSegmentsIntersect
(
const
GeoLib
::
Polyline
*
ply
,
std
::
size_t
&
idx0
,
std
::
size_t
&
idx1
,
GeoLib
::
Point
&
intersection_pnt
);
bool
lineSegmentsIntersect
(
const
GeoLib
::
Polyline
*
ply
,
std
::
size_t
&
idx0
,
std
::
size_t
&
idx1
,
GeoLib
::
Point
&
intersection_pnt
);
/**
* A line segment is given by its two end-points. The function checks,
...
...
@@ -124,6 +130,6 @@ bool lineSegmentsIntersect (const GeoLib::Polyline* ply, std::size_t &idx0, std:
bool
lineSegmentIntersect
(
const
GeoLib
::
Point
&
a
,
const
GeoLib
::
Point
&
b
,
const
GeoLib
::
Point
&
c
,
const
GeoLib
::
Point
&
d
,
GeoLib
::
Point
&
s
);
}
// end namespace
Math
Lib
}
// end namespace
Geo
Lib
#endif
/*
MATHTOOLS
_H_ */
#endif
/*
ANALYTICAL_GEOMETRY
_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment