I'm going to be throwing a mesh into a BEM acoustic simulator.

There is a well-known resonance problem with BEM acoustic simulators --if you test for a frequency that matches one of the resonance modes of the mesh, it goes crazy.

There is a known workaround which involves creating random points inside the mesh, so that's what I would like to do.

How would I go about implementing a python script to do this?

I'm assuming scripting is the best way, please someone correct me if I'm wrong here.

EDIT: how about picking a random point-pair P Q, intercepting it with the mesh, and if there are exactly 2 points of intersection A and B, then use A + t(B-A) where t is randomly chosen between 0 and 1

For a closed mesh of a human head and shoulders (so mostly convex), a significant number of points pairs should produce a valid result

The only question is: can I determine the points at which a line hits a mesh?

EDIT: mathutils.geometry.intersect_ray_tri from http://www.blender.org/documentation/blender_python_api_2_65_5/mathutils.geometry.html

EDIT: http://www.blender.org/documentation/248PythonDoc/Mesh.Mesh-class.html#pointInside


2 Answers 2


There is way to do this without python, using particles.

  1. Create a particle system and pick volume and random as the distribution settings:

    enter image description here

    Also set the physics to none to conserve processing power.

    You'll want to set the Number to 10000, but I don't think the computer I'm currently on will like that :P.

  2. Create a one-vertex object. The easiest way to do this is by adding a plane and deleting three vertices. After you delete the extra verts, switch back to object mode (Tab) and press ShiftCtrlAltC> Origin to geometry to snap the origin to the single vertex.

  3. Pick your single vertex object as the particle system object in Particles > Render:

    enter image description here

  4. With the object with the particle system selected, press Convert on the particle modifier in the modifiers tab:

    enter image description here

  5. Join the resulting vertices to your object with CtrlJ (everything should already be selected correctly). Remember to remove the particle system, as pressing Convert does not delete it.


enter image description here

  • $\begingroup$ I am having a huge problem. I really need to use this technique for a project of mine, but when I press "convert", nothing happens. Sometimes, if I change either of the booleans that appear in the toolbox upon pressing "convert" - that is, the "parent" and "keep hierarchy" buttons - all the duplicated objects disappear and I find one little duplication in the corner of the emitter mesh. It is very strange. Do you have any idea how to counter this and make all the particles convert to individual objects like they're supposed to? Do you think this could possibly be a bug? $\endgroup$ Commented May 24, 2015 at 22:19
  • $\begingroup$ Actually, never mind! The way I figured it out, well, let's just say it was a bug. There was a question that was referencing this answer to solve answer the question, and it mentioned that a keyboard shortcut for the convert button was Ctrl + Shift + A. I used that and... everything seems to be smooth sailing. Here's that said question. It's got to be a bug. $\endgroup$ Commented May 24, 2015 at 22:26

There's a utility function to generate random points on faces:

import bpy_extras.mesh_utils
bpy_extras.mesh_utils.face_random_points(num_points, tessfaces)
Generates a list of random points over mesh tessfaces.
:arg num_points: the number of random points to generate on each face.
:type int:
:arg tessfaces: list of the faces to generate points on.
:type tessfaces: :class:`bpy.types.MeshTessFace`, sequence
:return: list of random points over all faces.
:rtype: list

Random points inside your mesh is more troublesome, since meshes aren't volume-based (there's not necessarily an inside). You could have a look at the 3D Print Toolbox addon, which is able to determine the volume of a mesh and uses normals and angles for that. You oculd probably use something similar to determine whether a point is inside the mesh or not (as long as the mesh is "solid").

  • $\begingroup$ wow, that's a gem I've been missing for a while! $\endgroup$
    – patmo141
    Commented Apr 19, 2018 at 1:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .