Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYVisibilityCone.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef __TY_VISIBILITY_CONE__
17 #define __TY_VISIBILITY_CONE__
18 
20 #include <gtest/gtest_prod.h>
21 
28 {
29 
30 public:
39  VisibilityCone(const OPoint3D& pA, const OPoint3D& pB, const OPoint3D& pC);
40 
47  bool segmentIsVisibleInCone(const OSegment3D& segmentToTest) const;
48 
49 private:
53  void setupNormalsOfCone();
54 
61  bool pointIsInCone(const OPoint3D& pM2D) const;
62 
70  bool segmentIntersectsBorderCone(const OPoint3D& pM2D, const OPoint3D& pN2D) const;
71 
79 
80  FRIEND_TEST(test_TYVisibilityCone, pointIsInCone);
81  FRIEND_TEST(test_TYVisibilityCone, segmentIntersectsBorderCone);
82 };
83 
92 inline OVector3D buildVector2D(const OPoint3D& pA2D, const OPoint3D& pB2D)
93 {
94  return OVector3D{pB2D._x - pA2D._x, pB2D._y - pA2D._y, 0.};
95 }
96 
105 bool segmentIntersectsSemiLine2D(const OVector3D& vAB, const OVector3D& vMN, const OVector3D& vAM);
106 
120 bool solveLin2x2(double a11, double a12, double a21, double a22, double b1, double b2, double& x1,
121  double& x2);
122 
123 #endif // __TY_VISIBILITY_CONE__
All base classes related to 3D manipulation.
bool solveLin2x2(double a11, double a12, double a21, double a22, double b1, double b2, double &x1, double &x2)
Solve a 2x2 linear system of equations Ax = b.
OVector3D buildVector2D(const OPoint3D &pA2D, const OPoint3D &pB2D)
Optimized way to build a vector in 2D (horizontal plane z = 0) from point A to B To use as a replacem...
bool segmentIntersectsSemiLine2D(const OVector3D &vAB, const OVector3D &vMN, const OVector3D &vAM)
Test if the segment [MN] intersects the semi-line [AB) in 2D (horizontal plane z = 0)
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
The 3D point class.
Definition: 3d.h:487
Class to define a segment.
Definition: 3d.h:1141
The 3D vector class.
Definition: 3d.h:298
bool segmentIntersectsBorderCone(const OPoint3D &pM2D, const OPoint3D &pN2D) const
Test if the segment [MN] intersects the borders of the visibility cone.
bool pointIsInCone(const OPoint3D &pM2D) const
Test if the point M lies inside the visibility cone.
bool segmentIsVisibleInCone(const OSegment3D &segmentToTest) const
Test if a segment is visible in the visibility cone.
FRIEND_TEST(test_TYVisibilityCone, pointIsInCone)
FRIEND_TEST(test_TYVisibilityCone, segmentIntersectsBorderCone)
void setupNormalsOfCone()
Compute exterior normal of the cone.
VisibilityCone(const OPoint3D &pA, const OPoint3D &pB, const OPoint3D &pC)
Builds a visibility cone spanned from point A into points B and C This cone is such that [BC] segment...