示例#1
0
    def calculatePoints(self):
        pos_x = -self.position.get_x()
        pos_y = -self.position.get_y()
        pos_z = -self.position.get_z()

        self.vertexList.append(self.position)
        self.vertexList.append(
            Vec3(
                self.position.get_x() + 0.25 * dimensions_room['length'],
                self.position.get_y() +
                0.25 * dimensions_room['length'] * tan(self.opening / 2),
                self.position.get_z() +
                0.25 * dimensions_room['length'] * tan(self.opening / 2)))
        self.vertexList.append(
            Vec3(
                self.position.get_x() + 0.25 * dimensions_room['length'],
                self.position.get_y() +
                0.25 * dimensions_room['length'] * tan(self.opening / 2),
                self.position.get_z() -
                0.25 * dimensions_room['length'] * tan(self.opening / 2)))
        self.vertexList.append(
            Vec3(
                self.position.get_x() + 0.25 * dimensions_room['length'],
                self.position.get_y() -
                0.25 * dimensions_room['length'] * tan(self.opening / 2),
                self.position.get_z() +
                0.25 * dimensions_room['length'] * tan(self.opening / 2)))
        self.vertexList.append(
            Vec3(
                self.position.get_x() + 0.25 * dimensions_room['length'],
                self.position.get_y() -
                0.25 * dimensions_room['length'] * tan(self.opening / 2),
                self.position.get_z() -
                0.25 * dimensions_room['length'] * tan(self.opening / 2)))
示例#2
0
 def _create_parabola(self):  # creates visualization of the parable, must finish!!!!!!!
     length, width, height = self.dimensions.get_tuple()
     r = ((height * height / 4) + length * length) / (2 * length)
     self.angle_ouverture = degrees(arcsin(height / (2 * r)))
     self.points_parable_origin = []
     self.points_parable = []
     rotation = Orientation(0, 90, 0)
     self.points_per_level = 10
     self.angle_levels = 10
     matRot = rotation.rotation_matrix()
     for theta in range(0, int(self.angle_ouverture), self.angle_levels):
         for phi in range(0, 360, int(360 / self.points_per_level)):
             theta_rad = radians(theta)
             phi_rad = radians(phi)
             x0 = r * sin(theta_rad) * cos(phi_rad)
             y0 = r * sin(theta_rad) * sin(phi_rad)
             z0 = r * (1 - sqrt(1 - sin(theta_rad) * sin(theta_rad)))
             p = Vec3(x0, y0, z0)
             p = matRot * p - Vec3(length / 2, 0, 0)
             p = Vec3(p.item(0), p.item(1), p.item(2))
             p2 = Vec3(p.item(0), p.item(1), p.item(2))
             self.points_parable_origin.append(p)
             self.points_parable.append(p2)
     self.squares_edges = []
     # for()
     self._update_vertices_points()
示例#3
0
    def convertXY(self, x, y):
        d = x * x + y * y
        radiusSquared = self.ballRadius * self.ballRadius
        if (d > radiusSquared):
            return Vec3(x, y, 0)

        else:
            return Vec3(x, y, sqrt(radiusSquared - d))
示例#4
0
 def get_haut_haut():
     return {
         'PF_000': Vec3(0, 0, Ideal.z),  # PF_000
         'PF_100': Vec3(Ideal.x, 0, Ideal.z),  # PF_100
         'PF_010': Vec3(0, Ideal.y, Ideal.z),  # PF_010
         'PF_110': Vec3(Ideal.x, Ideal.y, Ideal.z),  # PF_110
         'PF_001': Vec3(0, 0, Ideal.z),  # PF_001
         'PF_101': Vec3(Ideal.x, 0, Ideal.z),  # PF_101
         'PF_011': Vec3(0, Ideal.y, Ideal.z),  # PF_011
         'PF_111': Vec3(Ideal.x, Ideal.y, Ideal.z)  # PF_111
     }
示例#5
0
    def test_new(self):

        v = Vec3(0.0, 0.0, 0.0)

        self.subTest('type Vec3')
        self.assertEqual(type(v), Vec3)

        self.subTest('is matrix')
        self.assertTrue(isinstance(v, matrix))

        self.subTest('shape')
        self.assertEqual(v.shape, (3, 1))
示例#6
0
 def _get_source_demo_config_ancrage(self):
     x_centre_source = sum(
         point.get_x()
         for point in self.config_ancrage.get_points_fixes()) / 8
     y_centre_source = sum(
         point.get_y()
         for point in self.config_ancrage.get_points_fixes()) / 8
     z_centre_source = self.chambre.dimensions['height'] / 2
     centre_demo = Vec3(x_centre_source, y_centre_source, z_centre_source)
     source_demo = Box(dimensions=self.dimensions_source,
                       centre=centre_demo,
                       ypr_angles=TupleAnglesRotation.ZERO())
     return source_demo
示例#7
0
    def _is_coliding(self, other_box: 'Box', k_discretisation=None) -> bool:
        """
        Tests if there are points on pave1's faces inside other_box.
        the function needs to be called twice to be sure that there are no intersections
        pave1: dictionary with dimensions(dictionary),_center(matrix 3x1), orientation(dictionary)
        k: (k+1)^2 = number of points to be tested on each face, the greater the k, the plus reliable the result.
        """
        # default value if needed
        k = k_discretisation if k_discretisation else DefaultValues.box_colision_k_dicretisation
        # dimensions
        length, width, height = self.dimensions.get_tuple()
        # points to test
        points_to_be_tested = []
        # create "points" on the faces
        for i in range(k + 1):
            for j in range(k + 1):
                # XZ faces
                x = i * length / k
                z = j * height / k
                points_to_be_tested.append(Vec3(x, 0, z))
                points_to_be_tested.append(Vec3(x, width, z))

                # XY faces
                x = i * length / k
                y = j * width / k
                points_to_be_tested.append(Vec3(x, y, 0))
                points_to_be_tested.append(Vec3(x, y, height))

                # YZ faces
                y = i * width / k
                z = j * height / k
                points_to_be_tested.append(Vec3(0, y, z))
                points_to_be_tested.append(Vec3(length, y, z))

        # test them
        for index in range(len(points_to_be_tested)):
            # rotate the point
            points_to_be_tested[index] = self.orientation.rotation_matrix * points_to_be_tested[index]

            # check type TODO: remove this assert
            assert isinstance(points_to_be_tested[index], Vec3), "problem here with vec3"
            # next line converts from 3d rotation matrix to vecteur3d
            # points_to_be_tested[index] = Vec3(points_to_be_tested[index].__getitem__((0, 0)),
            #                                   points_to_be_tested[index].__getitem__((1, 0)),
            #                                   points_to_be_tested[index].__getitem__((2, 0)))
            halves = Vec3(length / 2, width / 2, height / 2)
            points_to_be_tested[index] = points_to_be_tested[index] + self.center + (-halves)
            # check if the point is in the other
            if other_box.is_in_box(points_to_be_tested[index]):
                return True

        return False
示例#8
0
 def __init__(self, dimensions_source, maisonette, chambre,
              config_ancrage: CableLayout, systeme_spherique_baie_vitree,
              configs_simulation):
     self.dimensions_source = dimensions_source
     self.maisonette = maisonette
     self.chambre = chambre
     self.config_ancrage = config_ancrage
     self.systeme_spherique_baie_vitree = systeme_spherique_baie_vitree
     self.diametre_cable = configs_simulation['diametre_cable']
     self.space_recherche = configs_simulation['space_recherche']
     self.n_discretisation_cables = configs_simulation[
         'n_discretisation_cables']
     self.k_dicretisation_cubes = configs_simulation[
         'k_dicretisation_cubes']
     self.verbose = configs_simulation['fmin_verbose']
     self.source = Box(centre=Vec3(0, 0, 0),
                       ypr_angles=TupleAnglesRotation(0, 0, 0),
                       dimensions=dimensions_source)
     self.limites = {}
     self._source_demo = self._get_source_demo_config_ancrage()
     self._cables_demo = self._get_cables_demo_config_ancrage()
示例#9
0
    def _set_sommets_inside(self):
        """TODO doc string"""
        points = self.vertices_points_list(BoxVertexOrderEnum.ZYX)
        S0 = points[0] - Vec3(-self.wall_width, -self.wall_width, -self.wall_width)
        S1 = points[1] - Vec3(-self.wall_width, -self.wall_width, self.wall_width)
        S2 = points[2] - Vec3(-self.wall_width, self.wall_width, -self.wall_width)
        S3 = points[3] - Vec3(-self.wall_width, self.wall_width, self.wall_width)

        S4 = points[4] - Vec3(self.wall_width, -self.wall_width, -self.wall_width)
        S5 = points[5] - Vec3(self.wall_width, -self.wall_width, self.wall_width)
        S6 = points[6] - Vec3(self.wall_width, self.wall_width, -self.wall_width)
        S7 = points[7] - Vec3(self.wall_width, self.wall_width, self.wall_width)

        length, width, height = self.dimensions.get_tuple()

        # window_inside_points

        S8 = points[1] - Vec3(-self.wall_width, -(width / 2 - self.window_dimensions['width'] / 2),
                                                    (height / 2 - self.window_dimensions['height'] / 2))
        S9 = points[3] - Vec3(-self.wall_width, (width / 2 - self.window_dimensions['width'] / 2),
                                                    (height / 2 - self.window_dimensions['height'] / 2))
        S10 = points[2] - Vec3(-self.wall_width, (width / 2 - self.window_dimensions['width'] / 2),
                                                     -(height / 2 - self.window_dimensions['height'] / 2))
        S11 = points[0] - Vec3(-self.wall_width, -(width / 2 - self.window_dimensions['width'] / 2),
                                                     -(height / 2 - self.window_dimensions['height'] / 2))

        #  window_outside_points

        S12 = points[1] - Vec3(0, -(width / 2 - self.window_dimensions['width'] / 2),
                                                     (height / 2 - self.window_dimensions['height'] / 2))
        S13 = points[3] - Vec3(0, (width / 2 - self.window_dimensions['width'] / 2),
                                                     (height / 2 - self.window_dimensions['height'] / 2))
        S14 = points[2] - Vec3(0, (width / 2 - self.window_dimensions['width'] / 2),
                                                     -(height / 2 - self.window_dimensions['height'] / 2))
        S15 = points[0] - Vec3(0, -(width / 2 - self.window_dimensions['width'] / 2),
                                                     -(height / 2 - self.window_dimensions['height'] / 2))

        S16 = points[0]
        S17 = points[1]
        S18 = points[2]
        S19 = points[3]

        self.sommets_extras = [S0, S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16, S17, S18, S19]
示例#10
0
    CableLayout, \
    CableConfiguration

from src.simulation.limit_angles.angles_limites import VerificateurAnglesLimites

'''
    Setup d'un faux systeme.
    Destiné juste à faire des debugs avec des valeurs plus simples.
'''

''' ************************ Maisonette ************************ '''
# _center
centre_maisonette = \
    Vec3(
        x=7500,  # mm
        y=5000,  # mm
        z=5000  # mm
    )

# dimensions
dimensions_maisonette = \
    BoxDimensions(
        length=5000,  # mm
        width=10000,  # mm
        height=10000  # mm
    )

# pave
maisonette = \
    Box(
        centre=centre_maisonette,
示例#11
0
    )

# rotation
rotation_systeme_spherique = \
    Orientation(
        yaw=180,  # degrés
        pitch=0,  # degrés
        row=0,    # degrés
        unity=AngleUnityEnum.degree,
    )

# systeme sphérique
systeme_spherique_baie_vitree = SphericalCoordinateSystem(
    center=centre_systeme_spherique, orientation=rotation_systeme_spherique)
''' ************************ Camera ************************ '''
camera_direction = Vec3(x=0, y=0, z=0)

# position
camera_position1 = Vec3(
    x=-dimensions_room['length'] / 2,  # mm
    y=-0.25 * dimensions_room['width'],  # mm
    z=-0.1 * dimensions_room['height']  # mm
)

camera_position2 = Vec3(
    x=-dimensions_room['length'] / 2,  # mm
    y=-0.25 * dimensions_room['width'],  # mm
    z=0.25 * dimensions_room['height']  # mm
)

camera_position3 = Vec3(
示例#12
0
 def direction_source_to_fixed(self) -> Vec3:
     """Unitary _vector in the direction source point -> fixed point."""
     return Vec3.zero() - self._vector.direction