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
a98c954c
Commit
a98c954c
authored
Apr 04, 2019
by
Daniel Filbert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added spherical uniform distribution to ITAGeoUtils
parent
848d3e13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
include/ITAGeo/Utils.h
include/ITAGeo/Utils.h
+28
-0
src/ITAGeo/Utils.cpp
src/ITAGeo/Utils.cpp
+44
-1
No files found.
include/ITAGeo/Utils.h
View file @
a98c954c
...
...
@@ -70,6 +70,34 @@ 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
/**
* @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
*/
ITA_GEO_API
void
ReflectRayOnFace
(
VistaRay
&
rRay
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
VistaVector3D
&
v3ReflectionPoint
);
//! Checks for intersection of a ray with a sphere
/**
* @return: true if an intersection is given
* @param[in] rRay: ray
* @param[in] pDetectionSphereCenter: center of detection sphere
* @param[in] fDetectionSphereRadius: radius of detection sphere
*/
ITA_GEO_API
bool
RayDetectionSphereIntersectionTest
(
const
VistaRay
&
rRay
,
std
::
shared_ptr
<
ITAGeo
::
CPropagationAnchor
>
pDetectionSphereCenter
,
float
fDetectionSphereRadius
,
VistaVector3D
&
v3DetectionPoint
);
//! 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]
*/
ITA_GEO_API
void
SetUniformlyDistributedSphericalCoordinateAngles
(
float
&
fRandomAzimuthAngle
,
float
&
fRandomElevationAngle
);
//! 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
ITAGeo
::
EIntersecting
IsLineIntersectingFace
(
const
VistaVector3D
&
v3StartPoint
,
const
VistaVector3D
&
v3EndPoint
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
);
//! Mirrors point over a plane
...
...
src/ITAGeo/Utils.cpp
View file @
a98c954c
...
...
@@ -4,6 +4,8 @@
#include <ITAException.h>
#include <ITAConstants.h>
#include <VistaCoreLibs/VistaTools/VistaRandomNumberGenerator.h>
#include <cassert>
bool
ITAGeoUtils
::
CalculateDiffractionAperturePoint
(
const
VistaRay
&
rInfiniteDiffractionEdge
,
const
VistaVector3D
&
v3SourcePos
,
const
VistaVector3D
&
v3TargetPos
,
VistaVector3D
&
v3AperturePoint
)
...
...
@@ -412,6 +414,47 @@ bool ITAGeoUtils::RayFaceIntersectionTest( const VistaRay& rRay, CITAMesh* pMesh
}
}
bool
ITAGeoUtils
::
RayDetectionSphereIntersectionTest
(
const
VistaRay
&
rRay
,
std
::
shared_ptr
<
ITAGeo
::
CPropagationAnchor
>
pDestination
,
float
fDetectionSphereRadius
,
VistaVector3D
&
v3DetectionPoint
)
{
const
VistaVector3D
v3RayOrigin2RcvPos
=
pDestination
->
v3InteractionPoint
-
rRay
.
GetOrigin
();
// Nearest Point of ray to detection sphere origin
v3DetectionPoint
=
rRay
.
GetDir
().
Dot
(
v3RayOrigin2RcvPos
)
*
rRay
.
GetDir
()
+
rRay
.
GetOrigin
();
return
((
v3DetectionPoint
-
pDestination
->
v3InteractionPoint
).
GetLength
()
<=
fDetectionSphereRadius
);
//float tDeviationAngle = acos(rRay.GetDir().Dot(v3RayOrigin2RcvPos.GetNormalized()));
//return (abs(v3RayOrigin2RcvPos.GetLength() * sin(tDeviationAngle)) < fDetectionSphereRadius);
}
void
ITAGeoUtils
::
ReflectRayOnFace
(
VistaRay
&
rRay
,
CITAMesh
*
pMesh
,
CITAMesh
::
FaceHandle
hFace
,
VistaVector3D
&
v3ReflectionPoint
)
{
assert
(
pMesh
->
has_face_normals
());
CITAMesh
::
Normal
normal
(
pMesh
->
normal
(
hFace
));
const
VistaVector3D
v3FaceNormal
(
normal
.
data
());
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
);
}
void
ITAGeoUtils
::
SetUniformlyDistributedSphericalCoordinateAngles
(
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
)
{
float
fPhi
,
fTheta
;
SetUniformlyDistributedSphericalCoordinateAngles
(
fPhi
,
fTheta
);
v3RandomDirection
.
SetValues
(
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
)
{
//The point of intersection in relation to the ray
...
...
@@ -706,4 +749,4 @@ bool ITAGeoUtils::VistaRaysFromOpenMeshFaceHalfedges( CITAMesh* pMesh, CITAMesh:
vRays
.
push_back
(
VistaRay
(
oStartPoint
,
oEndPoint
-
oStartPoint
)
);
}
return
true
;
}
}
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