pyroomacoustics
pyroomacoustics copied to clipboard
Negative volume on importing stl mesh
- On importing stl mesh file I get negative volume for it. Can someone help me in figuring out why?
- 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)
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.
""" 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
Can you please provide the STL file ?