pyroomacoustics icon indicating copy to clipboard operation
pyroomacoustics copied to clipboard

Negative volume on importing stl mesh

Open parmodhattri opened this issue 2 years ago • 3 comments

  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)

parmodhattri avatar Nov 24 '21 07:11 parmodhattri

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.

fakufaku avatar Nov 24 '21 08:11 fakufaku

""" 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_microphone_array(np.c_[np.array([2.2, 2.2, 2.5])]) )

To check the arguments for ray tracing.

room.rt_args

parmodhattri avatar Nov 25 '21 04:11 parmodhattri

Can you please provide the STL file ?

fakufaku avatar Nov 25 '21 05:11 fakufaku