LCAV / pyroomacoustics

Pyroomacoustics is a package for audio signal processing for indoor applications. It was developed as a fast prototyping platform for beamforming algorithms in indoor scenarios.
https://pyroomacoustics.readthedocs.io
MIT License
1.45k stars 432 forks source link

Negative volume on importing stl mesh #241

Closed parmodhattri closed 6 days ago

parmodhattri commented 2 years ago

  1. On importing stl mesh file I get negative volume for it. Can someone help me in figuring out why?
  2. I have created triangular mesh for a cube of 5m side.

from stl import mesh the_mesh = mesh.Mesh.from_file(filename="cube5m_reshuffled.stl") volume, COG, inertia_matrix=the_mesh.get_mass_properties() print('volume is', volume)

fakufaku commented 2 years ago

Hi @parmodhattri , the volume computation routine (and pyroomacoustics in general) assumes that the surface normals are all pointing outward from the room. Also there should be no holes in the mesh.

parmodhattri commented 2 years ago

""" Hi @fakufaku thanks for the response. Yes, surface normals are pointing outwards but don't have any holes in the mesh. And when I create room with this mesh for ray tracing (as shown below), it computes -ve no of rays for ray tracing (in room.rt_args). Can you help me in solving this?

"""

code

from stl import mesh import pyroomacoustics as pra import numpy as np the_mesh = mesh.Mesh.from_file(filename="cube5m_reshuffled.stl") volume, COG, inertia_matrix=the_mesh.get_mass_properties()

Create one wall per triangle

walls = [] for w in range(ntriang): walls.append( pra.wall_factory( np.array(the_mesh.vectors[w].T / size_reduc_factor), material.energy_absorption["coeffs"], material.scattering["coeffs"], ) )

Creating room from mesh

room = ( pra.Room( walls, fs=16000, max_order=1, ray_tracing=True, air_absorption=True) .add_source(np.array([2.5, 2.5, 2.5]).reshape(3,1),signal=signal) .add_microphonearray(np.c[np.array([2.2, 2.2, 2.5])]) )

To check the arguments for ray tracing.

room.rt_args

fakufaku commented 2 years ago

Can you please provide the STL file ?

fakufaku commented 6 days ago

Closed due to lack of activity.