Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITAGeo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Institute of Technical Acoustics (ITA)
ITAGeo
Commits
25933f56
Commit
25933f56
authored
Apr 15, 2019
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some util function refactoring
parent
112f33d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
include/ITAGeo/Base.h
include/ITAGeo/Base.h
+7
-2
include/ITAGeo/Utils.h
include/ITAGeo/Utils.h
+11
-10
src/ITAGeo/Utils.cpp
src/ITAGeo/Utils.cpp
+6
-7
No files found.
include/ITAGeo/Base.h
View file @
25933f56
...
...
@@ -388,10 +388,15 @@ namespace ITAGeo
inline
double
GetLength
()
const
{
double
dLength
=
0.0
;
for
(
size_t
i
=
1
;
i
<
this
->
size
();
i
++
)
{
//Add length of sub path
dLength
+=
(
at
(
i
)
->
v3InteractionPoint
-
at
(
i
-
1
)
->
v3InteractionPoint
).
GetLength
();
auto
&
v3From
(
at
(
i
-
1
)
->
v3InteractionPoint
);
auto
&
v3To
(
at
(
i
)
->
v3InteractionPoint
);
const
double
dSegmentLength
=
(
v3To
-
v3From
).
GetLength
();
// Add length of sub path
dLength
+=
dSegmentLength
;
}
return
dLength
;
...
...
include/ITAGeo/Utils.h
View file @
25933f56
...
...
@@ -70,14 +70,15 @@ namespace ITAGeoUtils
//! Returns only true, if a ray casts through given mesh face, false otherwise
ITA_GEO_API
bool
RayFaceIntersectionTest
(
const
VistaRay
&
rRay
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
VistaVector3D
&
v3IntersectionPoint
,
ITAGeo
::
ECulling
eFaceCulling
=
ITAGeo
::
ECulling
::
BACKFACE
);
//!
Changes direction of incident ray according to the principle of specular reflection
//!
Returns reflected direction of incident ray according to the principle of specular reflection (Snells law)
/**
* @param[out] rRay: Incident ray which direction is to be changed
* @param[in] pMesh: Mesh of the scene
* @param[in] hFace: Face handle for identifying the corresponding reflection face
* @param[in] v3ReflectionPoint: Point of specular reflection on the face
* @param[in] pMesh Mesh of the scene
* @param[in] hFace Face handle for identifying the corresponding reflection face
* @param[in] rRay Incident ray which direction is to be changed
*
* @return Direction of specular reflection
*/
ITA_GEO_API
void
ReflectRayOnFace
(
VistaRay
&
rRay
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
VistaVector3D
&
v3ReflectionPoint
);
ITA_GEO_API
VistaVector3D
GetReflectedDirection
(
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
const
VistaRay
&
rRay
);
//! Checks for intersection of a ray with a sphere
/**
...
...
@@ -90,13 +91,13 @@ namespace ITAGeoUtils
//! Sets random angles according to uniformly distributed PDF on the surface of the unity sphere
/**
* @param[out] fRandomAzimuthAngle: randomly distributed in the range [0, 2*pi]
* @param[out] fRandomElevationAngle: randomly distributed in the range [0, pi]
* @param[out] fRandomAzimuthAngle
Rad
: randomly distributed in the range [0, 2*pi]
* @param[out] fRandomElevationAngle
Rad
: randomly distributed in the range [0, pi]
*/
ITA_GEO_API
void
SetUniformlyDistributedSphericalCoordinateAngles
(
float
&
fRandomAzimuthAngle
,
float
&
fRandomElevationAngle
);
ITA_GEO_API
void
GetUniformlyDistributedSphericalCoordinateAngles
(
float
&
fRandomAzimuthAngleRad
,
float
&
fRandomElevationAngleRad
);
//! Creates vector which random direction is uniformly distributed on the surface of the unity sphere
ITA_GEO_API
void
SetUniformlyDistributedSphericalRandomDirection
(
VistaVector3D
&
v3RandomDirection
);
ITA_GEO_API
VistaVector3D
GetUniformlyDistributedSphericalRandomDirection
(
);
ITA_GEO_API
ITAGeo
::
EIntersecting
IsLineIntersectingFace
(
const
VistaVector3D
&
v3StartPoint
,
const
VistaVector3D
&
v3EndPoint
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
);
...
...
src/ITAGeo/Utils.cpp
View file @
25933f56
...
...
@@ -427,7 +427,7 @@ bool ITAGeoUtils::RayDetectionSphereIntersectionTest(const VistaRay& rRay, std::
//return (abs(v3RayOrigin2RcvPos.GetLength() * sin(tDeviationAngle)) < fDetectionSphereRadius);
}
void
ITAGeoUtils
::
ReflectRayOnFace
(
VistaRay
&
rRay
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
VistaVector3D
&
v3ReflectionPoint
)
VistaVector3D
ITAGeoUtils
::
GetReflectedDirection
(
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
const
VistaRay
&
rRay
)
{
assert
(
pMesh
->
has_face_normals
());
...
...
@@ -437,22 +437,21 @@ void ITAGeoUtils::ReflectRayOnFace(VistaRay& rRay, CITAMesh* pMesh, CITAMesh::Fa
VistaVector3D
v3OrthogonalComponent
=
rRay
.
GetDir
().
Dot
(
v3FaceNormal
)
*
v3FaceNormal
;
// direction component of incident ray orthogonal to reflection face
//! Change direction of ray orthogonal to reflection wall into the opposite direction
rRay
.
SetDir
(
rRay
.
GetDir
()
-
2
*
v3OrthogonalComponent
);
rRay
.
SetOrigin
(
v3ReflectionPoint
);
return
rRay
.
GetDir
()
-
2
*
v3OrthogonalComponent
;
}
void
ITAGeoUtils
::
S
etUniformlyDistributedSphericalCoordinateAngles
(
float
&
fRandomAzimuthAngle
,
float
&
fRandomElevationAngle
)
void
ITAGeoUtils
::
G
etUniformlyDistributedSphericalCoordinateAngles
(
float
&
fRandomAzimuthAngle
,
float
&
fRandomElevationAngle
)
{
fRandomAzimuthAngle
=
2
*
ITAConstants
::
PI_F
*
VistaRandomNumberGenerator
::
GetStandardRNG
()
->
GenerateFloat
(
0.0
f
,
1.0
f
);
fRandomElevationAngle
=
acos
(
1.0
f
-
2.0
f
*
VistaRandomNumberGenerator
::
GetStandardRNG
()
->
GenerateFloat
(
0.0
f
,
1.0
f
));
}
void
ITAGeoUtils
::
SetUniformlyDistributedSphericalRandomDirection
(
VistaVector3D
&
v3RandomDirection
)
VistaVector3D
ITAGeoUtils
::
GetUniformlyDistributedSphericalRandomDirection
(
)
{
float
fPhi
,
fTheta
;
S
etUniformlyDistributedSphericalCoordinateAngles
(
fPhi
,
fTheta
);
G
etUniformlyDistributedSphericalCoordinateAngles
(
fPhi
,
fTheta
);
v3RandomDirection
.
SetValues
(
cos
(
fPhi
)
*
sin
(
fTheta
),
sin
(
fPhi
)
*
sin
(
fTheta
),
cos
(
fTheta
));
return
VistaVector3D
(
cos
(
fPhi
)
*
sin
(
fTheta
),
sin
(
fPhi
)
*
sin
(
fTheta
),
cos
(
fTheta
));
}
ITAGeo
::
EIntersecting
ITAGeoUtils
::
IsLineIntersectingFace
(
const
VistaVector3D
&
v3StartPoint
,
const
VistaVector3D
&
v3EndPoint
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
)
...
...
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